documentation.d.ts 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207
  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. get 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 get 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 set LogLevels(level: 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 get 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. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  482. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  483. /**
  484. * Returns client's state
  485. */
  486. get readyState(): number;
  487. /**
  488. * Returns client's status
  489. */
  490. get status(): number;
  491. /**
  492. * Returns client's status as a text
  493. */
  494. get statusText(): string;
  495. /**
  496. * Returns client's response
  497. */
  498. get response(): any;
  499. /**
  500. * Returns client's response url
  501. */
  502. get responseURL(): string;
  503. /**
  504. * Returns client's response as text
  505. */
  506. get responseText(): string;
  507. /**
  508. * Gets or sets the expected response type
  509. */
  510. get responseType(): XMLHttpRequestResponseType;
  511. set responseType(value: XMLHttpRequestResponseType);
  512. /** @hidden */
  513. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  514. /** @hidden */
  515. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  516. /**
  517. * Cancels any network activity
  518. */
  519. abort(): void;
  520. /**
  521. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  522. * @param body defines an optional request body
  523. */
  524. send(body?: Document | BodyInit | null): void;
  525. /**
  526. * Sets the request method, request URL
  527. * @param method defines the method to use (GET, POST, etc..)
  528. * @param url defines the url to connect with
  529. */
  530. open(method: string, url: string): void;
  531. /**
  532. * Sets the value of a request header.
  533. * @param name The name of the header whose value is to be set
  534. * @param value The value to set as the body of the header
  535. */
  536. setRequestHeader(name: string, value: string): void;
  537. /**
  538. * Get the string containing the text of a particular header's value.
  539. * @param name The name of the header
  540. * @returns The string containing the text of the given header name
  541. */
  542. getResponseHeader(name: string): Nullable<string>;
  543. }
  544. }
  545. declare module BABYLON {
  546. /**
  547. * File request interface
  548. */
  549. export interface IFileRequest {
  550. /**
  551. * Raised when the request is complete (success or error).
  552. */
  553. onCompleteObservable: Observable<IFileRequest>;
  554. /**
  555. * Aborts the request for a file.
  556. */
  557. abort: () => void;
  558. }
  559. }
  560. declare module BABYLON {
  561. /**
  562. * Define options used to create a render target texture
  563. */
  564. export class RenderTargetCreationOptions {
  565. /**
  566. * Specifies is mipmaps must be generated
  567. */
  568. generateMipMaps?: boolean;
  569. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  570. generateDepthBuffer?: boolean;
  571. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  572. generateStencilBuffer?: boolean;
  573. /** Defines texture type (int by default) */
  574. type?: number;
  575. /** Defines sampling mode (trilinear by default) */
  576. samplingMode?: number;
  577. /** Defines format (RGBA by default) */
  578. format?: number;
  579. }
  580. }
  581. declare module BABYLON {
  582. /** Defines the cross module used constants to avoid circular dependncies */
  583. export class Constants {
  584. /** Defines that alpha blending is disabled */
  585. static readonly ALPHA_DISABLE: number;
  586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  587. static readonly ALPHA_ADD: number;
  588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  589. static readonly ALPHA_COMBINE: number;
  590. /** Defines that alpha blending is DEST - SRC * DEST */
  591. static readonly ALPHA_SUBTRACT: number;
  592. /** Defines that alpha blending is SRC * DEST */
  593. static readonly ALPHA_MULTIPLY: number;
  594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  595. static readonly ALPHA_MAXIMIZED: number;
  596. /** Defines that alpha blending is SRC + DEST */
  597. static readonly ALPHA_ONEONE: number;
  598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  599. static readonly ALPHA_PREMULTIPLIED: number;
  600. /**
  601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  603. */
  604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  606. static readonly ALPHA_INTERPOLATE: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_SCREENMODE: number;
  612. /**
  613. * Defines that alpha blending is SRC + DST
  614. * Alpha will be set to SRC ALPHA + DST ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEONE: number;
  617. /**
  618. * Defines that alpha blending is SRC * DST ALPHA + DST
  619. * Alpha will be set to 0
  620. */
  621. static readonly ALPHA_ALPHATOCOLOR: number;
  622. /**
  623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  624. */
  625. static readonly ALPHA_REVERSEONEMINUS: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  629. */
  630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  631. /**
  632. * Defines that alpha blending is SRC + DST
  633. * Alpha will be set to SRC ALPHA
  634. */
  635. static readonly ALPHA_ONEONE_ONEZERO: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. * Alpha will be set to DST ALPHA
  639. */
  640. static readonly ALPHA_EXCLUSION: number;
  641. /** Defines that alpha blending equation a SUM */
  642. static readonly ALPHA_EQUATION_ADD: number;
  643. /** Defines that alpha blending equation a SUBSTRACTION */
  644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  647. /** Defines that alpha blending equation a MAX operation */
  648. static readonly ALPHA_EQUATION_MAX: number;
  649. /** Defines that alpha blending equation a MIN operation */
  650. static readonly ALPHA_EQUATION_MIN: number;
  651. /**
  652. * Defines that alpha blending equation a DARKEN operation:
  653. * It takes the min of the src and sums the alpha channels.
  654. */
  655. static readonly ALPHA_EQUATION_DARKEN: number;
  656. /** Defines that the ressource is not delayed*/
  657. static readonly DELAYLOADSTATE_NONE: number;
  658. /** Defines that the ressource was successfully delay loaded */
  659. static readonly DELAYLOADSTATE_LOADED: number;
  660. /** Defines that the ressource is currently delay loading */
  661. static readonly DELAYLOADSTATE_LOADING: number;
  662. /** Defines that the ressource is delayed and has not started loading */
  663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  665. static readonly NEVER: number;
  666. /** 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 */
  667. static readonly ALWAYS: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  669. static readonly LESS: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  671. static readonly EQUAL: number;
  672. /** 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 */
  673. static readonly LEQUAL: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  675. static readonly GREATER: number;
  676. /** 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 */
  677. static readonly GEQUAL: number;
  678. /** 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 */
  679. static readonly NOTEQUAL: number;
  680. /** Passed to stencilOperation to specify that stencil value must be kept */
  681. static readonly KEEP: number;
  682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  683. static readonly REPLACE: number;
  684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  685. static readonly INCR: number;
  686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  687. static readonly DECR: number;
  688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  689. static readonly INVERT: number;
  690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  691. static readonly INCR_WRAP: number;
  692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  693. static readonly DECR_WRAP: number;
  694. /** Texture is not repeating outside of 0..1 UVs */
  695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  696. /** Texture is repeating outside of 0..1 UVs */
  697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  698. /** Texture is repeating and mirrored */
  699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  700. /** ALPHA */
  701. static readonly TEXTUREFORMAT_ALPHA: number;
  702. /** LUMINANCE */
  703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  704. /** LUMINANCE_ALPHA */
  705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  706. /** RGB */
  707. static readonly TEXTUREFORMAT_RGB: number;
  708. /** RGBA */
  709. static readonly TEXTUREFORMAT_RGBA: number;
  710. /** RED */
  711. static readonly TEXTUREFORMAT_RED: number;
  712. /** RED (2nd reference) */
  713. static readonly TEXTUREFORMAT_R: number;
  714. /** RG */
  715. static readonly TEXTUREFORMAT_RG: number;
  716. /** RED_INTEGER */
  717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  718. /** RED_INTEGER (2nd reference) */
  719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  720. /** RG_INTEGER */
  721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  722. /** RGB_INTEGER */
  723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  724. /** RGBA_INTEGER */
  725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  726. /** UNSIGNED_BYTE */
  727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  728. /** UNSIGNED_BYTE (2nd reference) */
  729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  730. /** FLOAT */
  731. static readonly TEXTURETYPE_FLOAT: number;
  732. /** HALF_FLOAT */
  733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  734. /** BYTE */
  735. static readonly TEXTURETYPE_BYTE: number;
  736. /** SHORT */
  737. static readonly TEXTURETYPE_SHORT: number;
  738. /** UNSIGNED_SHORT */
  739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  740. /** INT */
  741. static readonly TEXTURETYPE_INT: number;
  742. /** UNSIGNED_INT */
  743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  744. /** UNSIGNED_SHORT_4_4_4_4 */
  745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  746. /** UNSIGNED_SHORT_5_5_5_1 */
  747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  748. /** UNSIGNED_SHORT_5_6_5 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  750. /** UNSIGNED_INT_2_10_10_10_REV */
  751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  752. /** UNSIGNED_INT_24_8 */
  753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  754. /** UNSIGNED_INT_10F_11F_11F_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  756. /** UNSIGNED_INT_5_9_9_9_REV */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  760. /** nearest is mag = nearest and min = nearest and no mip */
  761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  762. /** mag = nearest and min = nearest and mip = none */
  763. static readonly TEXTURE_NEAREST_NEAREST: number;
  764. /** Bilinear is mag = linear and min = linear and no mip */
  765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  766. /** mag = linear and min = linear and mip = none */
  767. static readonly TEXTURE_LINEAR_LINEAR: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** Trilinear is mag = linear and min = linear and mip = linear */
  771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  772. /** mag = nearest and min = nearest and mip = nearest */
  773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  774. /** mag = nearest and min = linear and mip = nearest */
  775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  776. /** mag = nearest and min = linear and mip = linear */
  777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  778. /** mag = nearest and min = linear and mip = none */
  779. static readonly TEXTURE_NEAREST_LINEAR: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** mag = linear and min = nearest and mip = nearest */
  783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  784. /** mag = linear and min = nearest and mip = linear */
  785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = none */
  789. static readonly TEXTURE_LINEAR_NEAREST: number;
  790. /** Explicit coordinates mode */
  791. static readonly TEXTURE_EXPLICIT_MODE: number;
  792. /** Spherical coordinates mode */
  793. static readonly TEXTURE_SPHERICAL_MODE: number;
  794. /** Planar coordinates mode */
  795. static readonly TEXTURE_PLANAR_MODE: number;
  796. /** Cubic coordinates mode */
  797. static readonly TEXTURE_CUBIC_MODE: number;
  798. /** Projection coordinates mode */
  799. static readonly TEXTURE_PROJECTION_MODE: number;
  800. /** Skybox coordinates mode */
  801. static readonly TEXTURE_SKYBOX_MODE: number;
  802. /** Inverse Cubic coordinates mode */
  803. static readonly TEXTURE_INVCUBIC_MODE: number;
  804. /** Equirectangular coordinates mode */
  805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  806. /** Equirectangular Fixed coordinates mode */
  807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  808. /** Equirectangular Fixed Mirrored coordinates mode */
  809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  810. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  811. static readonly SCALEMODE_FLOOR: number;
  812. /** Defines that texture rescaling will look for the nearest power of 2 size */
  813. static readonly SCALEMODE_NEAREST: number;
  814. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  815. static readonly SCALEMODE_CEILING: number;
  816. /**
  817. * The dirty texture flag value
  818. */
  819. static readonly MATERIAL_TextureDirtyFlag: number;
  820. /**
  821. * The dirty light flag value
  822. */
  823. static readonly MATERIAL_LightDirtyFlag: number;
  824. /**
  825. * The dirty fresnel flag value
  826. */
  827. static readonly MATERIAL_FresnelDirtyFlag: number;
  828. /**
  829. * The dirty attribute flag value
  830. */
  831. static readonly MATERIAL_AttributesDirtyFlag: number;
  832. /**
  833. * The dirty misc flag value
  834. */
  835. static readonly MATERIAL_MiscDirtyFlag: number;
  836. /**
  837. * The all dirty flag value
  838. */
  839. static readonly MATERIAL_AllDirtyFlag: number;
  840. /**
  841. * Returns the triangle fill mode
  842. */
  843. static readonly MATERIAL_TriangleFillMode: number;
  844. /**
  845. * Returns the wireframe mode
  846. */
  847. static readonly MATERIAL_WireFrameFillMode: number;
  848. /**
  849. * Returns the point fill mode
  850. */
  851. static readonly MATERIAL_PointFillMode: number;
  852. /**
  853. * Returns the point list draw mode
  854. */
  855. static readonly MATERIAL_PointListDrawMode: number;
  856. /**
  857. * Returns the line list draw mode
  858. */
  859. static readonly MATERIAL_LineListDrawMode: number;
  860. /**
  861. * Returns the line loop draw mode
  862. */
  863. static readonly MATERIAL_LineLoopDrawMode: number;
  864. /**
  865. * Returns the line strip draw mode
  866. */
  867. static readonly MATERIAL_LineStripDrawMode: number;
  868. /**
  869. * Returns the triangle strip draw mode
  870. */
  871. static readonly MATERIAL_TriangleStripDrawMode: number;
  872. /**
  873. * Returns the triangle fan draw mode
  874. */
  875. static readonly MATERIAL_TriangleFanDrawMode: number;
  876. /**
  877. * Stores the clock-wise side orientation
  878. */
  879. static readonly MATERIAL_ClockWiseSideOrientation: number;
  880. /**
  881. * Stores the counter clock-wise side orientation
  882. */
  883. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  884. /**
  885. * Nothing
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_NothingTrigger: number;
  889. /**
  890. * On pick
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPickTrigger: number;
  894. /**
  895. * On left pick
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnLeftPickTrigger: number;
  899. /**
  900. * On right pick
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnRightPickTrigger: number;
  904. /**
  905. * On center pick
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnCenterPickTrigger: number;
  909. /**
  910. * On pick down
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickDownTrigger: number;
  914. /**
  915. * On double pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnDoublePickTrigger: number;
  919. /**
  920. * On pick up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickUpTrigger: number;
  924. /**
  925. * On pick out.
  926. * This trigger will only be raised if you also declared a OnPickDown
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickOutTrigger: number;
  930. /**
  931. * On long press
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnLongPressTrigger: number;
  935. /**
  936. * On pointer over
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPointerOverTrigger: number;
  940. /**
  941. * On pointer out
  942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  943. */
  944. static readonly ACTION_OnPointerOutTrigger: number;
  945. /**
  946. * On every frame
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnEveryFrameTrigger: number;
  950. /**
  951. * On intersection enter
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnIntersectionEnterTrigger: number;
  955. /**
  956. * On intersection exit
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnIntersectionExitTrigger: number;
  960. /**
  961. * On key down
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnKeyDownTrigger: number;
  965. /**
  966. * On key up
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnKeyUpTrigger: number;
  970. /**
  971. * Billboard mode will only apply to Y axis
  972. */
  973. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  974. /**
  975. * Billboard mode will apply to all axes
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  978. /**
  979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  983. * Test order :
  984. * Is the bounding sphere outside the frustum ?
  985. * If not, are the bounding box vertices outside the frustum ?
  986. * It not, then the cullable object is in the frustum.
  987. */
  988. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  989. /** Culling strategy : Bounding Sphere Only.
  990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  991. * It's also less accurate than the standard because some not visible objects can still be selected.
  992. * Test : is the bounding sphere outside the frustum ?
  993. * If not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  996. /** Culling strategy : Optimistic Inclusion.
  997. * This in an inclusion test first, then the standard exclusion test.
  998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  999. * 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.
  1000. * Anyway, it's as accurate as the standard strategy.
  1001. * Test :
  1002. * Is the cullable object bounding sphere center in the frustum ?
  1003. * If not, apply the default culling strategy.
  1004. */
  1005. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1009. * 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.
  1010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1011. * Test :
  1012. * Is the cullable object bounding sphere center in the frustum ?
  1013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1016. /**
  1017. * No logging while loading
  1018. */
  1019. static readonly SCENELOADER_NO_LOGGING: number;
  1020. /**
  1021. * Minimal logging while loading
  1022. */
  1023. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1024. /**
  1025. * Summary logging while loading
  1026. */
  1027. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1028. /**
  1029. * Detailled logging while loading
  1030. */
  1031. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * This represents the required contract to create a new type of texture loader.
  1037. */
  1038. export interface IInternalTextureLoader {
  1039. /**
  1040. * Defines wether the loader supports cascade loading the different faces.
  1041. */
  1042. supportCascades: boolean;
  1043. /**
  1044. * This returns if the loader support the current file information.
  1045. * @param extension defines the file extension of the file being loaded
  1046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1047. * @param fallback defines the fallback internal texture if any
  1048. * @param isBase64 defines whether the texture is encoded as a base64
  1049. * @param isBuffer defines whether the texture data are stored as a buffer
  1050. * @returns true if the loader can load the specified file
  1051. */
  1052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1053. /**
  1054. * Transform the url before loading if required.
  1055. * @param rootUrl the url of the texture
  1056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1057. * @returns the transformed texture
  1058. */
  1059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1060. /**
  1061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1062. * @param rootUrl the url of the texture
  1063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1064. * @returns the fallback texture
  1065. */
  1066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1067. /**
  1068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module BABYLON {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1100. }
  1101. }
  1102. declare module BABYLON {
  1103. /**
  1104. * Class used to store gfx data (like WebGLBuffer)
  1105. */
  1106. export class DataBuffer {
  1107. /**
  1108. * Gets or sets the number of objects referencing this buffer
  1109. */
  1110. references: number;
  1111. /** Gets or sets the size of the underlying buffer */
  1112. capacity: number;
  1113. /**
  1114. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1115. */
  1116. is32Bits: boolean;
  1117. /**
  1118. * Gets the underlying buffer
  1119. */
  1120. get underlyingResource(): any;
  1121. }
  1122. }
  1123. declare module BABYLON {
  1124. /** @hidden */
  1125. export interface IShaderProcessor {
  1126. attributeProcessor?: (attribute: string) => string;
  1127. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1128. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1129. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1130. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1131. lineProcessor?: (line: string, isFragment: boolean) => string;
  1132. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /** @hidden */
  1156. export class ShaderCodeNode {
  1157. line: string;
  1158. children: ShaderCodeNode[];
  1159. additionalDefineKey?: string;
  1160. additionalDefineValue?: string;
  1161. isValid(preprocessors: {
  1162. [key: string]: string;
  1163. }): boolean;
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderCodeCursor {
  1172. private _lines;
  1173. lineIndex: number;
  1174. get currentLine(): string;
  1175. get canRead(): boolean;
  1176. set lines(value: string[]);
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /** @hidden */
  1189. export class ShaderDefineExpression {
  1190. isTrue(preprocessors: {
  1191. [key: string]: string;
  1192. }): boolean;
  1193. }
  1194. }
  1195. declare module BABYLON {
  1196. /** @hidden */
  1197. export class ShaderCodeTestNode extends ShaderCodeNode {
  1198. testExpression: ShaderDefineExpression;
  1199. isValid(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1207. define: string;
  1208. not: boolean;
  1209. constructor(define: string, not?: boolean);
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1218. leftOperand: ShaderDefineExpression;
  1219. rightOperand: ShaderDefineExpression;
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module BABYLON {
  1248. /**
  1249. * Class used to enable access to offline support
  1250. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1251. */
  1252. export interface IOfflineProvider {
  1253. /**
  1254. * Gets a boolean indicating if scene must be saved in the database
  1255. */
  1256. enableSceneOffline: boolean;
  1257. /**
  1258. * Gets a boolean indicating if textures must be saved in the database
  1259. */
  1260. enableTexturesOffline: boolean;
  1261. /**
  1262. * Open the offline support and make it available
  1263. * @param successCallback defines the callback to call on success
  1264. * @param errorCallback defines the callback to call on error
  1265. */
  1266. open(successCallback: () => void, errorCallback: () => void): void;
  1267. /**
  1268. * Loads an image from the offline support
  1269. * @param url defines the url to load from
  1270. * @param image defines the target DOM image
  1271. */
  1272. loadImage(url: string, image: HTMLImageElement): void;
  1273. /**
  1274. * Loads a file from offline support
  1275. * @param url defines the URL to load from
  1276. * @param sceneLoaded defines a callback to call on success
  1277. * @param progressCallBack defines a callback to call when progress changed
  1278. * @param errorCallback defines a callback to call on error
  1279. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1280. */
  1281. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1282. }
  1283. }
  1284. declare module BABYLON {
  1285. /**
  1286. * Class used to help managing file picking and drag'n'drop
  1287. * File Storage
  1288. */
  1289. export class FilesInputStore {
  1290. /**
  1291. * List of files ready to be loaded
  1292. */
  1293. static FilesToLoad: {
  1294. [key: string]: File;
  1295. };
  1296. }
  1297. }
  1298. declare module BABYLON {
  1299. /**
  1300. * Class used to define a retry strategy when error happens while loading assets
  1301. */
  1302. export class RetryStrategy {
  1303. /**
  1304. * Function used to defines an exponential back off strategy
  1305. * @param maxRetries defines the maximum number of retries (3 by default)
  1306. * @param baseInterval defines the interval between retries
  1307. * @returns the strategy function to use
  1308. */
  1309. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1310. }
  1311. }
  1312. declare module BABYLON {
  1313. /**
  1314. * @ignore
  1315. * Application error to support additional information when loading a file
  1316. */
  1317. export abstract class BaseError extends Error {
  1318. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /** @ignore */
  1323. export class LoadFileError extends BaseError {
  1324. request?: WebRequest;
  1325. file?: File;
  1326. /**
  1327. * Creates a new LoadFileError
  1328. * @param message defines the message of the error
  1329. * @param request defines the optional web request
  1330. * @param file defines the optional file
  1331. */
  1332. constructor(message: string, object?: WebRequest | File);
  1333. }
  1334. /** @ignore */
  1335. export class RequestFileError extends BaseError {
  1336. request: WebRequest;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. */
  1342. constructor(message: string, request: WebRequest);
  1343. }
  1344. /** @ignore */
  1345. export class ReadFileError extends BaseError {
  1346. file: File;
  1347. /**
  1348. * Creates a new ReadFileError
  1349. * @param message defines the message of the error
  1350. * @param file defines the optional file
  1351. */
  1352. constructor(message: string, file: File);
  1353. }
  1354. /**
  1355. * @hidden
  1356. */
  1357. export class FileTools {
  1358. /**
  1359. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1360. */
  1361. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1362. /**
  1363. * Gets or sets the base URL to use to load assets
  1364. */
  1365. static BaseUrl: string;
  1366. /**
  1367. * Default behaviour for cors in the application.
  1368. * It can be a string if the expected behavior is identical in the entire app.
  1369. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1370. */
  1371. static CorsBehavior: string | ((url: string | string[]) => string);
  1372. /**
  1373. * Gets or sets a function used to pre-process url before using them to load assets
  1374. */
  1375. static PreprocessUrl: (url: string) => string;
  1376. /**
  1377. * Removes unwanted characters from an url
  1378. * @param url defines the url to clean
  1379. * @returns the cleaned url
  1380. */
  1381. private static _CleanUrl;
  1382. /**
  1383. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1384. * @param url define the url we are trying
  1385. * @param element define the dom element where to configure the cors policy
  1386. */
  1387. static SetCorsBehavior(url: string | string[], element: {
  1388. crossOrigin: string | null;
  1389. }): void;
  1390. /**
  1391. * Loads an image as an HTMLImageElement.
  1392. * @param input url string, ArrayBuffer, or Blob to load
  1393. * @param onLoad callback called when the image successfully loads
  1394. * @param onError callback called when the image fails to load
  1395. * @param offlineProvider offline provider for caching
  1396. * @param mimeType optional mime type
  1397. * @returns the HTMLImageElement of the loaded image
  1398. */
  1399. 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>;
  1400. /**
  1401. * Reads a file from a File object
  1402. * @param file defines the file to load
  1403. * @param onSuccess defines the callback to call when data is loaded
  1404. * @param onProgress defines the callback to call during loading process
  1405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1406. * @param onError defines the callback to call when an error occurs
  1407. * @returns a file request object
  1408. */
  1409. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1410. /**
  1411. * Loads a file from a url
  1412. * @param url url to load
  1413. * @param onSuccess callback called when the file successfully loads
  1414. * @param onProgress callback called while file is loading (if the server supports this mode)
  1415. * @param offlineProvider defines the offline provider for caching
  1416. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1417. * @param onError callback called when the file fails to load
  1418. * @returns a file request object
  1419. */
  1420. 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;
  1421. /**
  1422. * Loads a file
  1423. * @param url url to load
  1424. * @param onSuccess callback called when the file successfully loads
  1425. * @param onProgress callback called while file is loading (if the server supports this mode)
  1426. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @param onOpened callback called when the web request is opened
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Checks if the loaded document was accessed via `file:`-Protocol.
  1434. * @returns boolean
  1435. */
  1436. static IsFileURL(): boolean;
  1437. }
  1438. }
  1439. declare module BABYLON {
  1440. /** @hidden */
  1441. export class ShaderProcessor {
  1442. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1443. private static _ProcessPrecision;
  1444. private static _ExtractOperation;
  1445. private static _BuildSubExpression;
  1446. private static _BuildExpression;
  1447. private static _MoveCursorWithinIf;
  1448. private static _MoveCursor;
  1449. private static _EvaluatePreProcessors;
  1450. private static _PreparePreProcessors;
  1451. private static _ProcessShaderConversion;
  1452. private static _ProcessIncludes;
  1453. /**
  1454. * Loads a file from a url
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param offlineProvider defines the offline provider for caching
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @returns a file request object
  1462. * @hidden
  1463. */
  1464. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1465. }
  1466. }
  1467. declare module BABYLON {
  1468. /**
  1469. * @hidden
  1470. */
  1471. export interface IColor4Like {
  1472. r: float;
  1473. g: float;
  1474. b: float;
  1475. a: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IColor3Like {
  1481. r: float;
  1482. g: float;
  1483. b: float;
  1484. }
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IVector4Like {
  1489. x: float;
  1490. y: float;
  1491. z: float;
  1492. w: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector3Like {
  1498. x: float;
  1499. y: float;
  1500. z: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector2Like {
  1506. x: float;
  1507. y: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IMatrixLike {
  1513. toArray(): DeepImmutable<Float32Array>;
  1514. updateFlag: int;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IViewportLike {
  1520. x: float;
  1521. y: float;
  1522. width: float;
  1523. height: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IPlaneLike {
  1529. normal: IVector3Like;
  1530. d: float;
  1531. normalize(): void;
  1532. }
  1533. }
  1534. declare module BABYLON {
  1535. /**
  1536. * Interface used to define common properties for effect fallbacks
  1537. */
  1538. export interface IEffectFallbacks {
  1539. /**
  1540. * Removes the defines that should be removed when falling back.
  1541. * @param currentDefines defines the current define statements for the shader.
  1542. * @param effect defines the current effect we try to compile
  1543. * @returns The resulting defines with defines of the current rank removed.
  1544. */
  1545. reduce(currentDefines: string, effect: Effect): string;
  1546. /**
  1547. * Removes the fallback from the bound mesh.
  1548. */
  1549. unBindMesh(): void;
  1550. /**
  1551. * Checks to see if more fallbacks are still availible.
  1552. */
  1553. hasMoreFallbacks: boolean;
  1554. }
  1555. }
  1556. declare module BABYLON {
  1557. /**
  1558. * Class used to evalaute queries containing `and` and `or` operators
  1559. */
  1560. export class AndOrNotEvaluator {
  1561. /**
  1562. * Evaluate a query
  1563. * @param query defines the query to evaluate
  1564. * @param evaluateCallback defines the callback used to filter result
  1565. * @returns true if the query matches
  1566. */
  1567. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1568. private static _HandleParenthesisContent;
  1569. private static _SimplifyNegation;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /**
  1574. * Class used to store custom tags
  1575. */
  1576. export class Tags {
  1577. /**
  1578. * Adds support for tags on the given object
  1579. * @param obj defines the object to use
  1580. */
  1581. static EnableFor(obj: any): void;
  1582. /**
  1583. * Removes tags support
  1584. * @param obj defines the object to use
  1585. */
  1586. static DisableFor(obj: any): void;
  1587. /**
  1588. * Gets a boolean indicating if the given object has tags
  1589. * @param obj defines the object to use
  1590. * @returns a boolean
  1591. */
  1592. static HasTags(obj: any): boolean;
  1593. /**
  1594. * Gets the tags available on a given object
  1595. * @param obj defines the object to use
  1596. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1597. * @returns the tags
  1598. */
  1599. static GetTags(obj: any, asString?: boolean): any;
  1600. /**
  1601. * Adds tags to an object
  1602. * @param obj defines the object to use
  1603. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1604. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1605. */
  1606. static AddTagsTo(obj: any, tagsString: string): void;
  1607. /**
  1608. * @hidden
  1609. */
  1610. static _AddTagTo(obj: any, tag: string): void;
  1611. /**
  1612. * Removes specific tags from a specific object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tags to remove
  1615. */
  1616. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _RemoveTagFrom(obj: any, tag: string): void;
  1621. /**
  1622. * Defines if tags hosted on an object match a given query
  1623. * @param obj defines the object to use
  1624. * @param tagsQuery defines the tag query
  1625. * @returns a boolean
  1626. */
  1627. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Scalar computation library
  1633. */
  1634. export class Scalar {
  1635. /**
  1636. * Two pi constants convenient for computation.
  1637. */
  1638. static TwoPi: number;
  1639. /**
  1640. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1641. * @param a number
  1642. * @param b number
  1643. * @param epsilon (default = 1.401298E-45)
  1644. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1645. */
  1646. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1647. /**
  1648. * Returns a string : the upper case translation of the number i to hexadecimal.
  1649. * @param i number
  1650. * @returns the upper case translation of the number i to hexadecimal.
  1651. */
  1652. static ToHex(i: number): string;
  1653. /**
  1654. * Returns -1 if value is negative and +1 is value is positive.
  1655. * @param value the value
  1656. * @returns the value itself if it's equal to zero.
  1657. */
  1658. static Sign(value: number): number;
  1659. /**
  1660. * Returns the value itself if it's between min and max.
  1661. * Returns min if the value is lower than min.
  1662. * Returns max if the value is greater than max.
  1663. * @param value the value to clmap
  1664. * @param min the min value to clamp to (default: 0)
  1665. * @param max the max value to clamp to (default: 1)
  1666. * @returns the clamped value
  1667. */
  1668. static Clamp(value: number, min?: number, max?: number): number;
  1669. /**
  1670. * the log2 of value.
  1671. * @param value the value to compute log2 of
  1672. * @returns the log2 of value.
  1673. */
  1674. static Log2(value: number): number;
  1675. /**
  1676. * Loops the value, so that it is never larger than length and never smaller than 0.
  1677. *
  1678. * This is similar to the modulo operator but it works with floating point numbers.
  1679. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1680. * With t = 5 and length = 2.5, the result would be 0.0.
  1681. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1682. * @param value the value
  1683. * @param length the length
  1684. * @returns the looped value
  1685. */
  1686. static Repeat(value: number, length: number): number;
  1687. /**
  1688. * Normalize the value between 0.0 and 1.0 using min and max values
  1689. * @param value value to normalize
  1690. * @param min max to normalize between
  1691. * @param max min to normalize between
  1692. * @returns the normalized value
  1693. */
  1694. static Normalize(value: number, min: number, max: number): number;
  1695. /**
  1696. * Denormalize the value from 0.0 and 1.0 using min and max values
  1697. * @param normalized value to denormalize
  1698. * @param min max to denormalize between
  1699. * @param max min to denormalize between
  1700. * @returns the denormalized value
  1701. */
  1702. static Denormalize(normalized: number, min: number, max: number): number;
  1703. /**
  1704. * Calculates the shortest difference between two given angles given in degrees.
  1705. * @param current current angle in degrees
  1706. * @param target target angle in degrees
  1707. * @returns the delta
  1708. */
  1709. static DeltaAngle(current: number, target: number): number;
  1710. /**
  1711. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1712. * @param tx value
  1713. * @param length length
  1714. * @returns The returned value will move back and forth between 0 and length
  1715. */
  1716. static PingPong(tx: number, length: number): number;
  1717. /**
  1718. * Interpolates between min and max with smoothing at the limits.
  1719. *
  1720. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1721. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1722. * @param from from
  1723. * @param to to
  1724. * @param tx value
  1725. * @returns the smooth stepped value
  1726. */
  1727. static SmoothStep(from: number, to: number, tx: number): number;
  1728. /**
  1729. * Moves a value current towards target.
  1730. *
  1731. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1732. * Negative values of maxDelta pushes the value away from target.
  1733. * @param current current value
  1734. * @param target target value
  1735. * @param maxDelta max distance to move
  1736. * @returns resulting value
  1737. */
  1738. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1739. /**
  1740. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1741. *
  1742. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1743. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting angle
  1748. */
  1749. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1752. * @param start start value
  1753. * @param end target value
  1754. * @param amount amount to lerp between
  1755. * @returns the lerped value
  1756. */
  1757. static Lerp(start: number, end: number, amount: number): number;
  1758. /**
  1759. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1760. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1761. * @param start start value
  1762. * @param end target value
  1763. * @param amount amount to lerp between
  1764. * @returns the lerped value
  1765. */
  1766. static LerpAngle(start: number, end: number, amount: number): number;
  1767. /**
  1768. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1769. * @param a start value
  1770. * @param b target value
  1771. * @param value value between a and b
  1772. * @returns the inverseLerp value
  1773. */
  1774. static InverseLerp(a: number, b: number, value: number): number;
  1775. /**
  1776. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1777. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1778. * @param value1 spline value
  1779. * @param tangent1 spline value
  1780. * @param value2 spline value
  1781. * @param tangent2 spline value
  1782. * @param amount input value
  1783. * @returns hermite result
  1784. */
  1785. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1786. /**
  1787. * Returns a random float number between and min and max values
  1788. * @param min min value of random
  1789. * @param max max value of random
  1790. * @returns random value
  1791. */
  1792. static RandomRange(min: number, max: number): number;
  1793. /**
  1794. * This function returns percentage of a number in a given range.
  1795. *
  1796. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1797. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1798. * @param number to convert to percentage
  1799. * @param min min range
  1800. * @param max max range
  1801. * @returns the percentage
  1802. */
  1803. static RangeToPercent(number: number, min: number, max: number): number;
  1804. /**
  1805. * This function returns number that corresponds to the percentage in a given range.
  1806. *
  1807. * PercentToRange(0.34,0,100) will return 34.
  1808. * @param percent to convert to number
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the number
  1812. */
  1813. static PercentToRange(percent: number, min: number, max: number): number;
  1814. /**
  1815. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1816. * @param angle The angle to normalize in radian.
  1817. * @return The converted angle.
  1818. */
  1819. static NormalizeRadians(angle: number): number;
  1820. }
  1821. }
  1822. declare module BABYLON {
  1823. /**
  1824. * Constant used to convert a value to gamma space
  1825. * @ignorenaming
  1826. */
  1827. export const ToGammaSpace: number;
  1828. /**
  1829. * Constant used to convert a value to linear space
  1830. * @ignorenaming
  1831. */
  1832. export const ToLinearSpace = 2.2;
  1833. /**
  1834. * Constant used to define the minimal number value in Babylon.js
  1835. * @ignorenaming
  1836. */
  1837. let Epsilon: number;
  1838. }
  1839. declare module BABYLON {
  1840. /**
  1841. * Class used to represent a viewport on screen
  1842. */
  1843. export class Viewport {
  1844. /** viewport left coordinate */
  1845. x: number;
  1846. /** viewport top coordinate */
  1847. y: number;
  1848. /**viewport width */
  1849. width: number;
  1850. /** viewport height */
  1851. height: number;
  1852. /**
  1853. * Creates a Viewport object located at (x, y) and sized (width, height)
  1854. * @param x defines viewport left coordinate
  1855. * @param y defines viewport top coordinate
  1856. * @param width defines the viewport width
  1857. * @param height defines the viewport height
  1858. */
  1859. constructor(
  1860. /** viewport left coordinate */
  1861. x: number,
  1862. /** viewport top coordinate */
  1863. y: number,
  1864. /**viewport width */
  1865. width: number,
  1866. /** viewport height */
  1867. height: number);
  1868. /**
  1869. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @returns a new Viewport
  1873. */
  1874. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1875. /**
  1876. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1877. * @param renderWidth defines the rendering width
  1878. * @param renderHeight defines the rendering height
  1879. * @param ref defines the target viewport
  1880. * @returns the current viewport
  1881. */
  1882. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1883. /**
  1884. * Returns a new Viewport copied from the current one
  1885. * @returns a new Viewport
  1886. */
  1887. clone(): Viewport;
  1888. }
  1889. }
  1890. declare module BABYLON {
  1891. /**
  1892. * Class containing a set of static utilities functions for arrays.
  1893. */
  1894. export class ArrayTools {
  1895. /**
  1896. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1897. * @param size the number of element to construct and put in the array
  1898. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1899. * @returns a new array filled with new objects
  1900. */
  1901. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1902. }
  1903. }
  1904. declare module BABYLON {
  1905. /**
  1906. * Class representing a vector containing 2 coordinates
  1907. */
  1908. export class Vector2 {
  1909. /** defines the first coordinate */
  1910. x: number;
  1911. /** defines the second coordinate */
  1912. y: number;
  1913. /**
  1914. * Creates a new Vector2 from the given x and y coordinates
  1915. * @param x defines the first coordinate
  1916. * @param y defines the second coordinate
  1917. */
  1918. constructor(
  1919. /** defines the first coordinate */
  1920. x?: number,
  1921. /** defines the second coordinate */
  1922. y?: number);
  1923. /**
  1924. * Gets a string with the Vector2 coordinates
  1925. * @returns a string with the Vector2 coordinates
  1926. */
  1927. toString(): string;
  1928. /**
  1929. * Gets class name
  1930. * @returns the string "Vector2"
  1931. */
  1932. getClassName(): string;
  1933. /**
  1934. * Gets current vector hash code
  1935. * @returns the Vector2 hash code as a number
  1936. */
  1937. getHashCode(): number;
  1938. /**
  1939. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1940. * @param array defines the source array
  1941. * @param index defines the offset in source array
  1942. * @returns the current Vector2
  1943. */
  1944. toArray(array: FloatArray, index?: number): Vector2;
  1945. /**
  1946. * Copy the current vector to an array
  1947. * @returns a new array with 2 elements: the Vector2 coordinates.
  1948. */
  1949. asArray(): number[];
  1950. /**
  1951. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1952. * @param source defines the source Vector2
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. copyFromFloats(x: number, y: number): Vector2;
  1963. /**
  1964. * Sets the Vector2 coordinates with the given floats
  1965. * @param x defines the first coordinate
  1966. * @param y defines the second coordinate
  1967. * @returns the current updated Vector2
  1968. */
  1969. set(x: number, y: number): Vector2;
  1970. /**
  1971. * Add another vector with the current one
  1972. * @param otherVector defines the other vector
  1973. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1974. */
  1975. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1976. /**
  1977. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @param result defines the target vector
  1980. * @returns the unmodified current Vector2
  1981. */
  1982. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1983. /**
  1984. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1985. * @param otherVector defines the other vector
  1986. * @returns the current updated Vector2
  1987. */
  1988. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1991. * @param otherVector defines the other vector
  1992. * @returns a new Vector2
  1993. */
  1994. addVector3(otherVector: Vector3): Vector2;
  1995. /**
  1996. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1997. * @param otherVector defines the other vector
  1998. * @returns a new Vector2
  1999. */
  2000. subtract(otherVector: Vector2): Vector2;
  2001. /**
  2002. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2003. * @param otherVector defines the other vector
  2004. * @param result defines the target vector
  2005. * @returns the unmodified current Vector2
  2006. */
  2007. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2008. /**
  2009. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns the current updated Vector2
  2012. */
  2013. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2014. /**
  2015. * Multiplies in place the current Vector2 coordinates by the given ones
  2016. * @param otherVector defines the other vector
  2017. * @returns the current updated Vector2
  2018. */
  2019. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2020. /**
  2021. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2022. * @param otherVector defines the other vector
  2023. * @returns a new Vector2
  2024. */
  2025. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2026. /**
  2027. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2028. * @param otherVector defines the other vector
  2029. * @param result defines the target vector
  2030. * @returns the unmodified current Vector2
  2031. */
  2032. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2033. /**
  2034. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2035. * @param x defines the first coordinate
  2036. * @param y defines the second coordinate
  2037. * @returns a new Vector2
  2038. */
  2039. multiplyByFloats(x: number, y: number): Vector2;
  2040. /**
  2041. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. divide(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Divides the current Vector2 coordinates by the given ones
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Gets a new Vector2 with current Vector2 negated coordinates
  2061. * @returns a new Vector2
  2062. */
  2063. negate(): Vector2;
  2064. /**
  2065. * Negate this vector in place
  2066. * @returns this
  2067. */
  2068. negateInPlace(): Vector2;
  2069. /**
  2070. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2071. * @param result defines the Vector3 object where to store the result
  2072. * @returns the current Vector2
  2073. */
  2074. negateToRef(result: Vector2): Vector2;
  2075. /**
  2076. * Multiply the Vector2 coordinates by scale
  2077. * @param scale defines the scaling factor
  2078. * @returns the current updated Vector2
  2079. */
  2080. scaleInPlace(scale: number): Vector2;
  2081. /**
  2082. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2083. * @param scale defines the scaling factor
  2084. * @returns a new Vector2
  2085. */
  2086. scale(scale: number): Vector2;
  2087. /**
  2088. * Scale the current Vector2 values by a factor to a given Vector2
  2089. * @param scale defines the scale factor
  2090. * @param result defines the Vector2 object where to store the result
  2091. * @returns the unmodified current Vector2
  2092. */
  2093. scaleToRef(scale: number, result: Vector2): Vector2;
  2094. /**
  2095. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2096. * @param scale defines the scale factor
  2097. * @param result defines the Vector2 object where to store the result
  2098. * @returns the unmodified current Vector2
  2099. */
  2100. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2101. /**
  2102. * Gets a boolean if two vectors are equals
  2103. * @param otherVector defines the other vector
  2104. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2105. */
  2106. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2107. /**
  2108. * Gets a boolean if two vectors are equals (using an epsilon value)
  2109. * @param otherVector defines the other vector
  2110. * @param epsilon defines the minimal distance to consider equality
  2111. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2112. */
  2113. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2114. /**
  2115. * Gets a new Vector2 from current Vector2 floored values
  2116. * @returns a new Vector2
  2117. */
  2118. floor(): Vector2;
  2119. /**
  2120. * Gets a new Vector2 from current Vector2 floored values
  2121. * @returns a new Vector2
  2122. */
  2123. fract(): Vector2;
  2124. /**
  2125. * Gets the length of the vector
  2126. * @returns the vector length (float)
  2127. */
  2128. length(): number;
  2129. /**
  2130. * Gets the vector squared length
  2131. * @returns the vector squared length (float)
  2132. */
  2133. lengthSquared(): number;
  2134. /**
  2135. * Normalize the vector
  2136. * @returns the current updated Vector2
  2137. */
  2138. normalize(): Vector2;
  2139. /**
  2140. * Gets a new Vector2 copied from the Vector2
  2141. * @returns a new Vector2
  2142. */
  2143. clone(): Vector2;
  2144. /**
  2145. * Gets a new Vector2(0, 0)
  2146. * @returns a new Vector2
  2147. */
  2148. static Zero(): Vector2;
  2149. /**
  2150. * Gets a new Vector2(1, 1)
  2151. * @returns a new Vector2
  2152. */
  2153. static One(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 set from the given index element of the given array
  2156. * @param array defines the data source
  2157. * @param offset defines the offset in the data source
  2158. * @returns a new Vector2
  2159. */
  2160. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2161. /**
  2162. * Sets "result" from the given index element of the given array
  2163. * @param array defines the data source
  2164. * @param offset defines the offset in the data source
  2165. * @param result defines the target vector
  2166. */
  2167. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2168. /**
  2169. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2170. * @param value1 defines 1st point of control
  2171. * @param value2 defines 2nd point of control
  2172. * @param value3 defines 3rd point of control
  2173. * @param value4 defines 4th point of control
  2174. * @param amount defines the interpolation factor
  2175. * @returns a new Vector2
  2176. */
  2177. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2178. /**
  2179. * 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".
  2180. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2181. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2182. * @param value defines the value to clamp
  2183. * @param min defines the lower limit
  2184. * @param max defines the upper limit
  2185. * @returns a new Vector2
  2186. */
  2187. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2190. * @param value1 defines the 1st control point
  2191. * @param tangent1 defines the outgoing tangent
  2192. * @param value2 defines the 2nd control point
  2193. * @param tangent2 defines the incoming tangent
  2194. * @param amount defines the interpolation factor
  2195. * @returns a new Vector2
  2196. */
  2197. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2198. /**
  2199. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2200. * @param start defines the start vector
  2201. * @param end defines the end vector
  2202. * @param amount defines the interpolation factor
  2203. * @returns a new Vector2
  2204. */
  2205. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2206. /**
  2207. * Gets the dot product of the vector "left" and the vector "right"
  2208. * @param left defines first vector
  2209. * @param right defines second vector
  2210. * @returns the dot product (float)
  2211. */
  2212. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2213. /**
  2214. * Returns a new Vector2 equal to the normalized given vector
  2215. * @param vector defines the vector to normalize
  2216. * @returns a new Vector2
  2217. */
  2218. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2221. * @param left defines 1st vector
  2222. * @param right defines 2nd vector
  2223. * @returns a new Vector2
  2224. */
  2225. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2228. * @param left defines 1st vector
  2229. * @param right defines 2nd vector
  2230. * @returns a new Vector2
  2231. */
  2232. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2233. /**
  2234. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2235. * @param vector defines the vector to transform
  2236. * @param transformation defines the matrix to apply
  2237. * @returns a new Vector2
  2238. */
  2239. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2240. /**
  2241. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2242. * @param vector defines the vector to transform
  2243. * @param transformation defines the matrix to apply
  2244. * @param result defines the target vector
  2245. */
  2246. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2247. /**
  2248. * Determines if a given vector is included in a triangle
  2249. * @param p defines the vector to test
  2250. * @param p0 defines 1st triangle point
  2251. * @param p1 defines 2nd triangle point
  2252. * @param p2 defines 3rd triangle point
  2253. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2254. */
  2255. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2256. /**
  2257. * Gets the distance between the vectors "value1" and "value2"
  2258. * @param value1 defines first vector
  2259. * @param value2 defines second vector
  2260. * @returns the distance between vectors
  2261. */
  2262. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2263. /**
  2264. * Returns the squared distance between the vectors "value1" and "value2"
  2265. * @param value1 defines first vector
  2266. * @param value2 defines second vector
  2267. * @returns the squared distance between vectors
  2268. */
  2269. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2270. /**
  2271. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2272. * @param value1 defines first vector
  2273. * @param value2 defines second vector
  2274. * @returns a new Vector2
  2275. */
  2276. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2277. /**
  2278. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2279. * @param p defines the middle point
  2280. * @param segA defines one point of the segment
  2281. * @param segB defines the other point of the segment
  2282. * @returns the shortest distance
  2283. */
  2284. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2285. }
  2286. /**
  2287. * Class used to store (x,y,z) vector representation
  2288. * A Vector3 is the main object used in 3D geometry
  2289. * It can represent etiher the coordinates of a point the space, either a direction
  2290. * Reminder: js uses a left handed forward facing system
  2291. */
  2292. export class Vector3 {
  2293. /**
  2294. * Defines the first coordinates (on X axis)
  2295. */
  2296. x: number;
  2297. /**
  2298. * Defines the second coordinates (on Y axis)
  2299. */
  2300. y: number;
  2301. /**
  2302. * Defines the third coordinates (on Z axis)
  2303. */
  2304. z: number;
  2305. private static _UpReadOnly;
  2306. private static _ZeroReadOnly;
  2307. /**
  2308. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2309. * @param x defines the first coordinates (on X axis)
  2310. * @param y defines the second coordinates (on Y axis)
  2311. * @param z defines the third coordinates (on Z axis)
  2312. */
  2313. constructor(
  2314. /**
  2315. * Defines the first coordinates (on X axis)
  2316. */
  2317. x?: number,
  2318. /**
  2319. * Defines the second coordinates (on Y axis)
  2320. */
  2321. y?: number,
  2322. /**
  2323. * Defines the third coordinates (on Z axis)
  2324. */
  2325. z?: number);
  2326. /**
  2327. * Creates a string representation of the Vector3
  2328. * @returns a string with the Vector3 coordinates.
  2329. */
  2330. toString(): string;
  2331. /**
  2332. * Gets the class name
  2333. * @returns the string "Vector3"
  2334. */
  2335. getClassName(): string;
  2336. /**
  2337. * Creates the Vector3 hash code
  2338. * @returns a number which tends to be unique between Vector3 instances
  2339. */
  2340. getHashCode(): number;
  2341. /**
  2342. * Creates an array containing three elements : the coordinates of the Vector3
  2343. * @returns a new array of numbers
  2344. */
  2345. asArray(): number[];
  2346. /**
  2347. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2348. * @param array defines the destination array
  2349. * @param index defines the offset in the destination array
  2350. * @returns the current Vector3
  2351. */
  2352. toArray(array: FloatArray, index?: number): Vector3;
  2353. /**
  2354. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2355. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2356. */
  2357. toQuaternion(): Quaternion;
  2358. /**
  2359. * Adds the given vector to the current Vector3
  2360. * @param otherVector defines the second operand
  2361. * @returns the current updated Vector3
  2362. */
  2363. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2364. /**
  2365. * Adds the given coordinates to the current Vector3
  2366. * @param x defines the x coordinate of the operand
  2367. * @param y defines the y coordinate of the operand
  2368. * @param z defines the z coordinate of the operand
  2369. * @returns the current updated Vector3
  2370. */
  2371. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2372. /**
  2373. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2374. * @param otherVector defines the second operand
  2375. * @returns the resulting Vector3
  2376. */
  2377. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2378. /**
  2379. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2385. /**
  2386. * Subtract the given vector from the current Vector3
  2387. * @param otherVector defines the second operand
  2388. * @returns the current updated Vector3
  2389. */
  2390. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2391. /**
  2392. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the resulting Vector3
  2395. */
  2396. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2399. * @param otherVector defines the second operand
  2400. * @param result defines the Vector3 object where to store the result
  2401. * @returns the current Vector3
  2402. */
  2403. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2404. /**
  2405. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2406. * @param x defines the x coordinate of the operand
  2407. * @param y defines the y coordinate of the operand
  2408. * @param z defines the z coordinate of the operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2412. /**
  2413. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2414. * @param x defines the x coordinate of the operand
  2415. * @param y defines the y coordinate of the operand
  2416. * @param z defines the z coordinate of the operand
  2417. * @param result defines the Vector3 object where to store the result
  2418. * @returns the current Vector3
  2419. */
  2420. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2421. /**
  2422. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2423. * @returns a new Vector3
  2424. */
  2425. negate(): Vector3;
  2426. /**
  2427. * Negate this vector in place
  2428. * @returns this
  2429. */
  2430. negateInPlace(): Vector3;
  2431. /**
  2432. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. negateToRef(result: Vector3): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. get isNonUniform(): boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static get UpReadOnly(): DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Negate this vector in place
  3160. * @returns this
  3161. */
  3162. negateInPlace(): Vector4;
  3163. /**
  3164. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3165. * @param result defines the Vector3 object where to store the result
  3166. * @returns the current Vector4
  3167. */
  3168. negateToRef(result: Vector4): Vector4;
  3169. /**
  3170. * Multiplies the current Vector4 coordinates by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns the updated Vector4.
  3173. */
  3174. scaleInPlace(scale: number): Vector4;
  3175. /**
  3176. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @returns a new vector with the result
  3179. */
  3180. scale(scale: number): Vector4;
  3181. /**
  3182. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3183. * @param scale the number to scale with
  3184. * @param result a vector to store the result in
  3185. * @returns the current Vector4.
  3186. */
  3187. scaleToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3190. * @param scale defines the scale factor
  3191. * @param result defines the Vector4 object where to store the result
  3192. * @returns the unmodified current Vector4
  3193. */
  3194. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3197. * @param otherVector the vector to compare against
  3198. * @returns true if they are equal
  3199. */
  3200. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3201. /**
  3202. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3203. * @param otherVector vector to compare against
  3204. * @param epsilon (Default: very small number)
  3205. * @returns true if they are equal
  3206. */
  3207. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3208. /**
  3209. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3210. * @param x x value to compare against
  3211. * @param y y value to compare against
  3212. * @param z z value to compare against
  3213. * @param w w value to compare against
  3214. * @returns true if equal
  3215. */
  3216. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3217. /**
  3218. * Multiplies in place the current Vector4 by the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns the updated Vector4.
  3221. */
  3222. multiplyInPlace(otherVector: Vector4): Vector4;
  3223. /**
  3224. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @returns resulting new vector
  3227. */
  3228. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3231. * @param otherVector vector to multiple with
  3232. * @param result vector to store the result
  3233. * @returns the current Vector4.
  3234. */
  3235. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3236. /**
  3237. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3238. * @param x x value multiply with
  3239. * @param y y value multiply with
  3240. * @param z z value multiply with
  3241. * @param w w value multiply with
  3242. * @returns resulting new vector
  3243. */
  3244. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3245. /**
  3246. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @returns resulting new vector
  3249. */
  3250. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3253. * @param otherVector vector to devide with
  3254. * @param result vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Divides the current Vector3 coordinates by the given ones.
  3260. * @param otherVector vector to devide with
  3261. * @returns the updated Vector3.
  3262. */
  3263. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3272. * @param other defines the second operand
  3273. * @returns the current updated Vector4
  3274. */
  3275. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Gets a new Vector4 from current Vector4 floored values
  3278. * @returns a new Vector4
  3279. */
  3280. floor(): Vector4;
  3281. /**
  3282. * Gets a new Vector4 from current Vector3 floored values
  3283. * @returns a new Vector4
  3284. */
  3285. fract(): Vector4;
  3286. /**
  3287. * Returns the Vector4 length (float).
  3288. * @returns the length
  3289. */
  3290. length(): number;
  3291. /**
  3292. * Returns the Vector4 squared length (float).
  3293. * @returns the length squared
  3294. */
  3295. lengthSquared(): number;
  3296. /**
  3297. * Normalizes in place the Vector4.
  3298. * @returns the updated Vector4.
  3299. */
  3300. normalize(): Vector4;
  3301. /**
  3302. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3303. * @returns this converted to a new vector3
  3304. */
  3305. toVector3(): Vector3;
  3306. /**
  3307. * Returns a new Vector4 copied from the current one.
  3308. * @returns the new cloned vector
  3309. */
  3310. clone(): Vector4;
  3311. /**
  3312. * Updates the current Vector4 with the given one coordinates.
  3313. * @param source the source vector to copy from
  3314. * @returns the updated Vector4.
  3315. */
  3316. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3317. /**
  3318. * Updates the current Vector4 coordinates with the given floats.
  3319. * @param x float to copy from
  3320. * @param y float to copy from
  3321. * @param z float to copy from
  3322. * @param w float to copy from
  3323. * @returns the updated Vector4.
  3324. */
  3325. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3326. /**
  3327. * Updates the current Vector4 coordinates with the given floats.
  3328. * @param x float to set from
  3329. * @param y float to set from
  3330. * @param z float to set from
  3331. * @param w float to set from
  3332. * @returns the updated Vector4.
  3333. */
  3334. set(x: number, y: number, z: number, w: number): Vector4;
  3335. /**
  3336. * Copies the given float to the current Vector3 coordinates
  3337. * @param v defines the x, y, z and w coordinates of the operand
  3338. * @returns the current updated Vector3
  3339. */
  3340. setAll(v: number): Vector4;
  3341. /**
  3342. * Returns a new Vector4 set from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @returns the new vector
  3346. */
  3347. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" from the starting index of the given Float32Array.
  3357. * @param array the array to pull values from
  3358. * @param offset the offset into the array to start at
  3359. * @param result the vector to store the result in
  3360. */
  3361. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3362. /**
  3363. * Updates the given vector "result" coordinates from the given floats.
  3364. * @param x float to set from
  3365. * @param y float to set from
  3366. * @param z float to set from
  3367. * @param w float to set from
  3368. * @param result the vector to the floats in
  3369. */
  3370. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3371. /**
  3372. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3373. * @returns the new vector
  3374. */
  3375. static Zero(): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3378. * @returns the new vector
  3379. */
  3380. static One(): Vector4;
  3381. /**
  3382. * Returns a new normalized Vector4 from the given one.
  3383. * @param vector the vector to normalize
  3384. * @returns the vector
  3385. */
  3386. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Updates the given vector "result" from the normalization of the given one.
  3389. * @param vector the vector to normalize
  3390. * @param result the vector to store the result in
  3391. */
  3392. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3393. /**
  3394. * Returns a vector with the minimum values from the left and right vectors
  3395. * @param left left vector to minimize
  3396. * @param right right vector to minimize
  3397. * @returns a new vector with the minimum of the left and right vector values
  3398. */
  3399. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns a vector with the maximum values from the left and right vectors
  3402. * @param left left vector to maximize
  3403. * @param right right vector to maximize
  3404. * @returns a new vector with the maximum of the left and right vector values
  3405. */
  3406. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3407. /**
  3408. * Returns the distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors
  3412. */
  3413. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the distance between
  3417. * @param value2 value to calulate the distance between
  3418. * @return the distance between the two vectors squared
  3419. */
  3420. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3421. /**
  3422. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3423. * @param value1 value to calulate the center between
  3424. * @param value2 value to calulate the center between
  3425. * @return the center between the two vectors
  3426. */
  3427. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3430. * This methods computes transformed normalized direction vectors only.
  3431. * @param vector the vector to transform
  3432. * @param transformation the transformation matrix to apply
  3433. * @returns the new vector
  3434. */
  3435. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3436. /**
  3437. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3438. * This methods computes transformed normalized direction vectors only.
  3439. * @param vector the vector to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the result in
  3442. */
  3443. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3446. * This methods computes transformed normalized direction vectors only.
  3447. * @param x value to transform
  3448. * @param y value to transform
  3449. * @param z value to transform
  3450. * @param w value to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @param result the vector to store the results in
  3453. */
  3454. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3455. /**
  3456. * Creates a new Vector4 from a Vector3
  3457. * @param source defines the source data
  3458. * @param w defines the 4th component (default is 0)
  3459. * @returns a new Vector4
  3460. */
  3461. static FromVector3(source: Vector3, w?: number): Vector4;
  3462. }
  3463. /**
  3464. * Class used to store quaternion data
  3465. * @see https://en.wikipedia.org/wiki/Quaternion
  3466. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3467. */
  3468. export class Quaternion {
  3469. /** defines the first component (0 by default) */
  3470. x: number;
  3471. /** defines the second component (0 by default) */
  3472. y: number;
  3473. /** defines the third component (0 by default) */
  3474. z: number;
  3475. /** defines the fourth component (1.0 by default) */
  3476. w: number;
  3477. /**
  3478. * Creates a new Quaternion from the given floats
  3479. * @param x defines the first component (0 by default)
  3480. * @param y defines the second component (0 by default)
  3481. * @param z defines the third component (0 by default)
  3482. * @param w defines the fourth component (1.0 by default)
  3483. */
  3484. constructor(
  3485. /** defines the first component (0 by default) */
  3486. x?: number,
  3487. /** defines the second component (0 by default) */
  3488. y?: number,
  3489. /** defines the third component (0 by default) */
  3490. z?: number,
  3491. /** defines the fourth component (1.0 by default) */
  3492. w?: number);
  3493. /**
  3494. * Gets a string representation for the current quaternion
  3495. * @returns a string with the Quaternion coordinates
  3496. */
  3497. toString(): string;
  3498. /**
  3499. * Gets the class name of the quaternion
  3500. * @returns the string "Quaternion"
  3501. */
  3502. getClassName(): string;
  3503. /**
  3504. * Gets a hash code for this quaternion
  3505. * @returns the quaternion hash code
  3506. */
  3507. getHashCode(): number;
  3508. /**
  3509. * Copy the quaternion to an array
  3510. * @returns a new array populated with 4 elements from the quaternion coordinates
  3511. */
  3512. asArray(): number[];
  3513. /**
  3514. * Check if two quaternions are equals
  3515. * @param otherQuaternion defines the second operand
  3516. * @return true if the current quaternion and the given one coordinates are strictly equals
  3517. */
  3518. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3519. /**
  3520. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3521. * @param otherQuaternion defines the other quaternion
  3522. * @param epsilon defines the minimal distance to consider equality
  3523. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3524. */
  3525. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3526. /**
  3527. * Clone the current quaternion
  3528. * @returns a new quaternion copied from the current one
  3529. */
  3530. clone(): Quaternion;
  3531. /**
  3532. * Copy a quaternion to the current one
  3533. * @param other defines the other quaternion
  3534. * @returns the updated current quaternion
  3535. */
  3536. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3537. /**
  3538. * Updates the current quaternion with the given float coordinates
  3539. * @param x defines the x coordinate
  3540. * @param y defines the y coordinate
  3541. * @param z defines the z coordinate
  3542. * @param w defines the w coordinate
  3543. * @returns the updated current quaternion
  3544. */
  3545. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3546. /**
  3547. * Updates the current quaternion from the given float coordinates
  3548. * @param x defines the x coordinate
  3549. * @param y defines the y coordinate
  3550. * @param z defines the z coordinate
  3551. * @param w defines the w coordinate
  3552. * @returns the updated current quaternion
  3553. */
  3554. set(x: number, y: number, z: number, w: number): Quaternion;
  3555. /**
  3556. * Adds two quaternions
  3557. * @param other defines the second operand
  3558. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3559. */
  3560. add(other: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Add a quaternion to the current one
  3563. * @param other defines the quaternion to add
  3564. * @returns the current quaternion
  3565. */
  3566. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3567. /**
  3568. * Subtract two quaternions
  3569. * @param other defines the second operand
  3570. * @returns a new quaternion as the subtraction result of the given one from the current one
  3571. */
  3572. subtract(other: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3577. */
  3578. scale(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies in place the current quaternion by a scale factor
  3588. * @param value defines the scale factor
  3589. * @returns the current modified quaternion
  3590. */
  3591. scaleInPlace(value: number): Quaternion;
  3592. /**
  3593. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3594. * @param scale defines the scale factor
  3595. * @param result defines the Quaternion object where to store the result
  3596. * @returns the unmodified current quaternion
  3597. */
  3598. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies two quaternions
  3601. * @param q1 defines the second operand
  3602. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3603. */
  3604. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @param result defines the target quaternion
  3609. * @returns the current quaternion
  3610. */
  3611. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3612. /**
  3613. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3614. * @param q1 defines the second operand
  3615. * @returns the currentupdated quaternion
  3616. */
  3617. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3618. /**
  3619. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3620. * @param ref defines the target quaternion
  3621. * @returns the current quaternion
  3622. */
  3623. conjugateToRef(ref: Quaternion): Quaternion;
  3624. /**
  3625. * Conjugates in place (1-q) the current quaternion
  3626. * @returns the current updated quaternion
  3627. */
  3628. conjugateInPlace(): Quaternion;
  3629. /**
  3630. * Conjugates in place (1-q) the current quaternion
  3631. * @returns a new quaternion
  3632. */
  3633. conjugate(): Quaternion;
  3634. /**
  3635. * Gets length of current quaternion
  3636. * @returns the quaternion length (float)
  3637. */
  3638. length(): number;
  3639. /**
  3640. * Normalize in place the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. normalize(): Quaternion;
  3644. /**
  3645. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns a new Vector3 containing the Euler angles
  3648. */
  3649. toEulerAngles(order?: string): Vector3;
  3650. /**
  3651. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3652. * @param result defines the vector which will be filled with the Euler angles
  3653. * @param order is a reserved parameter and is ignore for now
  3654. * @returns the current unchanged quaternion
  3655. */
  3656. toEulerAnglesToRef(result: Vector3): Quaternion;
  3657. /**
  3658. * Updates the given rotation matrix with the current quaternion values
  3659. * @param result defines the target matrix
  3660. * @returns the current unchanged quaternion
  3661. */
  3662. toRotationMatrix(result: Matrix): Quaternion;
  3663. /**
  3664. * Updates the current quaternion from the given rotation matrix values
  3665. * @param matrix defines the source matrix
  3666. * @returns the current updated quaternion
  3667. */
  3668. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3669. /**
  3670. * Creates a new quaternion from a rotation matrix
  3671. * @param matrix defines the source matrix
  3672. * @returns a new quaternion created from the given rotation matrix values
  3673. */
  3674. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3675. /**
  3676. * Updates the given quaternion with the given rotation matrix values
  3677. * @param matrix defines the source matrix
  3678. * @param result defines the target quaternion
  3679. */
  3680. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3681. /**
  3682. * Returns the dot product (float) between the quaternions "left" and "right"
  3683. * @param left defines the left operand
  3684. * @param right defines the right operand
  3685. * @returns the dot product
  3686. */
  3687. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3688. /**
  3689. * Checks if the two quaternions are close to each other
  3690. * @param quat0 defines the first quaternion to check
  3691. * @param quat1 defines the second quaternion to check
  3692. * @returns true if the two quaternions are close to each other
  3693. */
  3694. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3695. /**
  3696. * Creates an empty quaternion
  3697. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3698. */
  3699. static Zero(): Quaternion;
  3700. /**
  3701. * Inverse a given quaternion
  3702. * @param q defines the source quaternion
  3703. * @returns a new quaternion as the inverted current quaternion
  3704. */
  3705. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3706. /**
  3707. * Inverse a given quaternion
  3708. * @param q defines the source quaternion
  3709. * @param result the quaternion the result will be stored in
  3710. * @returns the result quaternion
  3711. */
  3712. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3713. /**
  3714. * Creates an identity quaternion
  3715. * @returns the identity quaternion
  3716. */
  3717. static Identity(): Quaternion;
  3718. /**
  3719. * Gets a boolean indicating if the given quaternion is identity
  3720. * @param quaternion defines the quaternion to check
  3721. * @returns true if the quaternion is identity
  3722. */
  3723. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3724. /**
  3725. * Creates a quaternion from a rotation around an axis
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3729. */
  3730. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3731. /**
  3732. * Creates a rotation around an axis and stores it into the given quaternion
  3733. * @param axis defines the axis to use
  3734. * @param angle defines the angle to use
  3735. * @param result defines the target quaternion
  3736. * @returns the target quaternion
  3737. */
  3738. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates a new quaternion from data stored into an array
  3741. * @param array defines the data source
  3742. * @param offset defines the offset in the source array where the data starts
  3743. * @returns a new quaternion
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  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 orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4923. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5251. /** Defines the x component of the start tangent in the bezier curve */
  5252. x1: number;
  5253. /** Defines the y component of the start tangent in the bezier curve */
  5254. y1: number;
  5255. /** Defines the x component of the end tangent in the bezier curve */
  5256. x2: number;
  5257. /** Defines the y component of the end tangent in the bezier curve */
  5258. y2: number;
  5259. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  5938. /** The frame for which the event is triggered **/
  5939. frame: number;
  5940. /** The event to perform when triggered **/
  5941. action: (currentFrame: number) => void;
  5942. /** Specifies if the event should be triggered only once**/
  5943. onlyOnce?: boolean | undefined;
  5944. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. 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);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. }
  7177. }
  7178. declare module BABYLON {
  7179. interface ThinEngine {
  7180. /**
  7181. * Create an uniform buffer
  7182. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7183. * @param elements defines the content of the uniform buffer
  7184. * @returns the webGL uniform buffer
  7185. */
  7186. createUniformBuffer(elements: FloatArray): DataBuffer;
  7187. /**
  7188. * Create a dynamic uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Update an existing uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param uniformBuffer defines the target uniform buffer
  7198. * @param elements defines the content to update
  7199. * @param offset defines the offset in the uniform buffer where update should start
  7200. * @param count defines the size of the data to update
  7201. */
  7202. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7203. /**
  7204. * Bind an uniform buffer to the current webGL context
  7205. * @param buffer defines the buffer to bind
  7206. */
  7207. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7208. /**
  7209. * Bind a buffer to the current webGL context at a given location
  7210. * @param buffer defines the buffer to bind
  7211. * @param location defines the index where to bind the buffer
  7212. */
  7213. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7214. /**
  7215. * Bind a specific block at a given index in a specific shader program
  7216. * @param pipelineContext defines the pipeline context to use
  7217. * @param blockName defines the block name
  7218. * @param index defines the index where to bind the block
  7219. */
  7220. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7221. }
  7222. }
  7223. declare module BABYLON {
  7224. /**
  7225. * Uniform buffer objects.
  7226. *
  7227. * Handles blocks of uniform on the GPU.
  7228. *
  7229. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7230. *
  7231. * For more information, please refer to :
  7232. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7233. */
  7234. export class UniformBuffer {
  7235. private _engine;
  7236. private _buffer;
  7237. private _data;
  7238. private _bufferData;
  7239. private _dynamic?;
  7240. private _uniformLocations;
  7241. private _uniformSizes;
  7242. private _uniformLocationPointer;
  7243. private _needSync;
  7244. private _noUBO;
  7245. private _currentEffect;
  7246. /** @hidden */
  7247. _alreadyBound: boolean;
  7248. private static _MAX_UNIFORM_SIZE;
  7249. private static _tempBuffer;
  7250. /**
  7251. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7252. * This is dynamic to allow compat with webgl 1 and 2.
  7253. * You will need to pass the name of the uniform as well as the value.
  7254. */
  7255. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7256. /**
  7257. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7258. * This is dynamic to allow compat with webgl 1 and 2.
  7259. * You will need to pass the name of the uniform as well as the value.
  7260. */
  7261. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7262. /**
  7263. * Lambda to Update a single float in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateFloat: (name: string, x: number) => void;
  7268. /**
  7269. * Lambda to Update a vec2 of float in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7274. /**
  7275. * Lambda to Update a vec3 of float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7280. /**
  7281. * Lambda to Update a vec4 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix: (name: string, mat: Matrix) => void;
  7292. /**
  7293. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateVector3: (name: string, vector: Vector3) => void;
  7298. /**
  7299. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateVector4: (name: string, vector: Vector4) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7316. /**
  7317. * Instantiates a new Uniform buffer objects.
  7318. *
  7319. * Handles blocks of uniform on the GPU.
  7320. *
  7321. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7322. *
  7323. * For more information, please refer to :
  7324. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7325. * @param engine Define the engine the buffer is associated with
  7326. * @param data Define the data contained in the buffer
  7327. * @param dynamic Define if the buffer is updatable
  7328. */
  7329. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7330. /**
  7331. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7332. * or just falling back on setUniformXXX calls.
  7333. */
  7334. get useUbo(): boolean;
  7335. /**
  7336. * Indicates if the WebGL underlying uniform buffer is in sync
  7337. * with the javascript cache data.
  7338. */
  7339. get isSync(): boolean;
  7340. /**
  7341. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7342. * Also, a dynamic UniformBuffer will disable cache verification and always
  7343. * update the underlying WebGL uniform buffer to the GPU.
  7344. * @returns if Dynamic, otherwise false
  7345. */
  7346. isDynamic(): boolean;
  7347. /**
  7348. * The data cache on JS side.
  7349. * @returns the underlying data as a float array
  7350. */
  7351. getData(): Float32Array;
  7352. /**
  7353. * The underlying WebGL Uniform buffer.
  7354. * @returns the webgl buffer
  7355. */
  7356. getBuffer(): Nullable<DataBuffer>;
  7357. /**
  7358. * std140 layout specifies how to align data within an UBO structure.
  7359. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7360. * for specs.
  7361. */
  7362. private _fillAlignment;
  7363. /**
  7364. * Adds an uniform in the buffer.
  7365. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7366. * for the layout to be correct !
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. * @param size Data size, or data directly.
  7369. */
  7370. addUniform(name: string, size: number | number[]): void;
  7371. /**
  7372. * Adds a Matrix 4x4 to the uniform buffer.
  7373. * @param name Name of the uniform, as used in the uniform block in the shader.
  7374. * @param mat A 4x4 matrix.
  7375. */
  7376. addMatrix(name: string, mat: Matrix): void;
  7377. /**
  7378. * Adds a vec2 to the uniform buffer.
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param x Define the x component value of the vec2
  7381. * @param y Define the y component value of the vec2
  7382. */
  7383. addFloat2(name: string, x: number, y: number): void;
  7384. /**
  7385. * Adds a vec3 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec3
  7388. * @param y Define the y component value of the vec3
  7389. * @param z Define the z component value of the vec3
  7390. */
  7391. addFloat3(name: string, x: number, y: number, z: number): void;
  7392. /**
  7393. * Adds a vec3 to the uniform buffer.
  7394. * @param name Name of the uniform, as used in the uniform block in the shader.
  7395. * @param color Define the vec3 from a Color
  7396. */
  7397. addColor3(name: string, color: Color3): void;
  7398. /**
  7399. * Adds a vec4 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. * @param color Define the rgb components from a Color
  7402. * @param alpha Define the a component of the vec4
  7403. */
  7404. addColor4(name: string, color: Color3, alpha: number): void;
  7405. /**
  7406. * Adds a vec3 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param vector Define the vec3 components from a Vector
  7409. */
  7410. addVector3(name: string, vector: Vector3): void;
  7411. /**
  7412. * Adds a Matrix 3x3 to the uniform buffer.
  7413. * @param name Name of the uniform, as used in the uniform block in the shader.
  7414. */
  7415. addMatrix3x3(name: string): void;
  7416. /**
  7417. * Adds a Matrix 2x2 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. */
  7420. addMatrix2x2(name: string): void;
  7421. /**
  7422. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7423. */
  7424. create(): void;
  7425. /** @hidden */
  7426. _rebuild(): void;
  7427. /**
  7428. * Updates the WebGL Uniform Buffer on the GPU.
  7429. * If the `dynamic` flag is set to true, no cache comparison is done.
  7430. * Otherwise, the buffer will be updated only if the cache differs.
  7431. */
  7432. update(): void;
  7433. /**
  7434. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7435. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7436. * @param data Define the flattened data
  7437. * @param size Define the size of the data.
  7438. */
  7439. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7440. private _valueCache;
  7441. private _cacheMatrix;
  7442. private _updateMatrix3x3ForUniform;
  7443. private _updateMatrix3x3ForEffect;
  7444. private _updateMatrix2x2ForEffect;
  7445. private _updateMatrix2x2ForUniform;
  7446. private _updateFloatForEffect;
  7447. private _updateFloatForUniform;
  7448. private _updateFloat2ForEffect;
  7449. private _updateFloat2ForUniform;
  7450. private _updateFloat3ForEffect;
  7451. private _updateFloat3ForUniform;
  7452. private _updateFloat4ForEffect;
  7453. private _updateFloat4ForUniform;
  7454. private _updateMatrixForEffect;
  7455. private _updateMatrixForUniform;
  7456. private _updateVector3ForEffect;
  7457. private _updateVector3ForUniform;
  7458. private _updateVector4ForEffect;
  7459. private _updateVector4ForUniform;
  7460. private _updateColor3ForEffect;
  7461. private _updateColor3ForUniform;
  7462. private _updateColor4ForEffect;
  7463. private _updateColor4ForUniform;
  7464. /**
  7465. * Sets a sampler uniform on the effect.
  7466. * @param name Define the name of the sampler.
  7467. * @param texture Define the texture to set in the sampler
  7468. */
  7469. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7470. /**
  7471. * Directly updates the value of the uniform in the cache AND on the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. */
  7475. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7476. /**
  7477. * Binds this uniform buffer to an effect.
  7478. * @param effect Define the effect to bind the buffer to
  7479. * @param name Name of the uniform block in the shader.
  7480. */
  7481. bindToEffect(effect: Effect, name: string): void;
  7482. /**
  7483. * Disposes the uniform buffer.
  7484. */
  7485. dispose(): void;
  7486. }
  7487. }
  7488. declare module BABYLON {
  7489. /**
  7490. * Enum that determines the text-wrapping mode to use.
  7491. */
  7492. export enum InspectableType {
  7493. /**
  7494. * Checkbox for booleans
  7495. */
  7496. Checkbox = 0,
  7497. /**
  7498. * Sliders for numbers
  7499. */
  7500. Slider = 1,
  7501. /**
  7502. * Vector3
  7503. */
  7504. Vector3 = 2,
  7505. /**
  7506. * Quaternions
  7507. */
  7508. Quaternion = 3,
  7509. /**
  7510. * Color3
  7511. */
  7512. Color3 = 4,
  7513. /**
  7514. * String
  7515. */
  7516. String = 5
  7517. }
  7518. /**
  7519. * Interface used to define custom inspectable properties.
  7520. * This interface is used by the inspector to display custom property grids
  7521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7522. */
  7523. export interface IInspectable {
  7524. /**
  7525. * Gets the label to display
  7526. */
  7527. label: string;
  7528. /**
  7529. * Gets the name of the property to edit
  7530. */
  7531. propertyName: string;
  7532. /**
  7533. * Gets the type of the editor to use
  7534. */
  7535. type: InspectableType;
  7536. /**
  7537. * Gets the minimum value of the property when using in "slider" mode
  7538. */
  7539. min?: number;
  7540. /**
  7541. * Gets the maximum value of the property when using in "slider" mode
  7542. */
  7543. max?: number;
  7544. /**
  7545. * Gets the setp to use when using in "slider" mode
  7546. */
  7547. step?: number;
  7548. }
  7549. }
  7550. declare module BABYLON {
  7551. /**
  7552. * Class used to provide helper for timing
  7553. */
  7554. export class TimingTools {
  7555. /**
  7556. * Polyfill for setImmediate
  7557. * @param action defines the action to execute after the current execution block
  7558. */
  7559. static SetImmediate(action: () => void): void;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to enable instatition of objects by class name
  7565. */
  7566. export class InstantiationTools {
  7567. /**
  7568. * Use this object to register external classes like custom textures or material
  7569. * to allow the laoders to instantiate them
  7570. */
  7571. static RegisteredExternalClasses: {
  7572. [key: string]: Object;
  7573. };
  7574. /**
  7575. * Tries to instantiate a new object from a given class name
  7576. * @param className defines the class name to instantiate
  7577. * @returns the new object or null if the system was not able to do the instantiation
  7578. */
  7579. static Instantiate(className: string): any;
  7580. }
  7581. }
  7582. declare module BABYLON {
  7583. /**
  7584. * Define options used to create a depth texture
  7585. */
  7586. export class DepthTextureCreationOptions {
  7587. /** Specifies whether or not a stencil should be allocated in the texture */
  7588. generateStencil?: boolean;
  7589. /** Specifies whether or not bilinear filtering is enable on the texture */
  7590. bilinearFiltering?: boolean;
  7591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7592. comparisonFunction?: number;
  7593. /** Specifies if the created texture is a cube texture */
  7594. isCube?: boolean;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. interface ThinEngine {
  7599. /**
  7600. * Creates a depth stencil cube texture.
  7601. * This is only available in WebGL 2.
  7602. * @param size The size of face edge in the cube texture.
  7603. * @param options The options defining the cube texture.
  7604. * @returns The cube texture
  7605. */
  7606. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7607. /**
  7608. * Creates a cube texture
  7609. * @param rootUrl defines the url where the files to load is located
  7610. * @param scene defines the current scene
  7611. * @param files defines the list of files to load (1 per face)
  7612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7613. * @param onLoad defines an optional callback raised when the texture is loaded
  7614. * @param onError defines an optional callback raised if there is an issue to load the texture
  7615. * @param format defines the format of the data
  7616. * @param forcedExtension defines the extension to use to pick the right loader
  7617. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7620. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. 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;
  7625. /**
  7626. * Creates a cube texture
  7627. * @param rootUrl defines the url where the files to load is located
  7628. * @param scene defines the current scene
  7629. * @param files defines the list of files to load (1 per face)
  7630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7631. * @param onLoad defines an optional callback raised when the texture is loaded
  7632. * @param onError defines an optional callback raised if there is an issue to load the texture
  7633. * @param format defines the format of the data
  7634. * @param forcedExtension defines the extension to use to pick the right loader
  7635. * @returns the cube texture as an InternalTexture
  7636. */
  7637. 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;
  7638. /**
  7639. * Creates a cube texture
  7640. * @param rootUrl defines the url where the files to load is located
  7641. * @param scene defines the current scene
  7642. * @param files defines the list of files to load (1 per face)
  7643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7644. * @param onLoad defines an optional callback raised when the texture is loaded
  7645. * @param onError defines an optional callback raised if there is an issue to load the texture
  7646. * @param format defines the format of the data
  7647. * @param forcedExtension defines the extension to use to pick the right loader
  7648. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /** @hidden */
  7655. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7656. /** @hidden */
  7657. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7660. /** @hidden */
  7661. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /**
  7663. * @hidden
  7664. */
  7665. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. /**
  7670. * Class for creating a cube texture
  7671. */
  7672. export class CubeTexture extends BaseTexture {
  7673. private _delayedOnLoad;
  7674. /**
  7675. * Observable triggered once the texture has been loaded.
  7676. */
  7677. onLoadObservable: Observable<CubeTexture>;
  7678. /**
  7679. * The url of the texture
  7680. */
  7681. url: string;
  7682. /**
  7683. * Gets or sets the center of the bounding box associated with the cube texture.
  7684. * It must define where the camera used to render the texture was set
  7685. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7686. */
  7687. boundingBoxPosition: Vector3;
  7688. private _boundingBoxSize;
  7689. /**
  7690. * Gets or sets the size of the bounding box associated with the cube texture
  7691. * When defined, the cubemap will switch to local mode
  7692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7693. * @example https://www.babylonjs-playground.com/#RNASML
  7694. */
  7695. set boundingBoxSize(value: Vector3);
  7696. /**
  7697. * Returns the bounding box size
  7698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7699. */
  7700. get boundingBoxSize(): Vector3;
  7701. protected _rotationY: number;
  7702. /**
  7703. * Sets texture matrix rotation angle around Y axis in radians.
  7704. */
  7705. set rotationY(value: number);
  7706. /**
  7707. * Gets texture matrix rotation angle around Y axis radians.
  7708. */
  7709. get rotationY(): number;
  7710. /**
  7711. * Are mip maps generated for this texture or not.
  7712. */
  7713. get noMipmap(): boolean;
  7714. private _noMipmap;
  7715. private _files;
  7716. protected _forcedExtension: Nullable<string>;
  7717. private _extensions;
  7718. private _textureMatrix;
  7719. private _format;
  7720. private _createPolynomials;
  7721. /** @hidden */
  7722. _prefiltered: boolean;
  7723. /**
  7724. * Creates a cube texture from an array of image urls
  7725. * @param files defines an array of image urls
  7726. * @param scene defines the hosting scene
  7727. * @param noMipmap specifies if mip maps are not used
  7728. * @returns a cube texture
  7729. */
  7730. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7731. /**
  7732. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7733. * @param url defines the url of the prefiltered texture
  7734. * @param scene defines the scene the texture is attached to
  7735. * @param forcedExtension defines the extension of the file if different from the url
  7736. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7737. * @return the prefiltered texture
  7738. */
  7739. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7740. /**
  7741. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7742. * as prefiltered data.
  7743. * @param rootUrl defines the url of the texture or the root name of the six images
  7744. * @param scene defines the scene the texture is attached to
  7745. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7746. * @param noMipmap defines if mipmaps should be created or not
  7747. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7748. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7749. * @param onError defines a callback triggered in case of error during load
  7750. * @param format defines the internal format to use for the texture once loaded
  7751. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7752. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7753. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7756. * @return the cube texture
  7757. */
  7758. 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);
  7759. /**
  7760. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7761. */
  7762. get isPrefiltered(): boolean;
  7763. /**
  7764. * Get the current class name of the texture useful for serialization or dynamic coding.
  7765. * @returns "CubeTexture"
  7766. */
  7767. getClassName(): string;
  7768. /**
  7769. * Update the url (and optional buffer) of this texture if url was null during construction.
  7770. * @param url the url of the texture
  7771. * @param forcedExtension defines the extension to use
  7772. * @param onLoad callback called when the texture is loaded (defaults to null)
  7773. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7774. */
  7775. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7776. /**
  7777. * Delays loading of the cube texture
  7778. * @param forcedExtension defines the extension to use
  7779. */
  7780. delayLoad(forcedExtension?: string): void;
  7781. /**
  7782. * Returns the reflection texture matrix
  7783. * @returns the reflection texture matrix
  7784. */
  7785. getReflectionTextureMatrix(): Matrix;
  7786. /**
  7787. * Sets the reflection texture matrix
  7788. * @param value Reflection texture matrix
  7789. */
  7790. setReflectionTextureMatrix(value: Matrix): void;
  7791. /**
  7792. * Parses text to create a cube texture
  7793. * @param parsedTexture define the serialized text to read from
  7794. * @param scene defines the hosting scene
  7795. * @param rootUrl defines the root url of the cube texture
  7796. * @returns a cube texture
  7797. */
  7798. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7799. /**
  7800. * Makes a clone, or deep copy, of the cube texture
  7801. * @returns a new cube texture
  7802. */
  7803. clone(): CubeTexture;
  7804. }
  7805. }
  7806. declare module BABYLON {
  7807. /**
  7808. * Manages the defines for the Material
  7809. */
  7810. export class MaterialDefines {
  7811. /** @hidden */
  7812. protected _keys: string[];
  7813. private _isDirty;
  7814. /** @hidden */
  7815. _renderId: number;
  7816. /** @hidden */
  7817. _areLightsDirty: boolean;
  7818. /** @hidden */
  7819. _areLightsDisposed: boolean;
  7820. /** @hidden */
  7821. _areAttributesDirty: boolean;
  7822. /** @hidden */
  7823. _areTexturesDirty: boolean;
  7824. /** @hidden */
  7825. _areFresnelDirty: boolean;
  7826. /** @hidden */
  7827. _areMiscDirty: boolean;
  7828. /** @hidden */
  7829. _areImageProcessingDirty: boolean;
  7830. /** @hidden */
  7831. _normals: boolean;
  7832. /** @hidden */
  7833. _uvs: boolean;
  7834. /** @hidden */
  7835. _needNormals: boolean;
  7836. /** @hidden */
  7837. _needUVs: boolean;
  7838. [id: string]: any;
  7839. /**
  7840. * Specifies if the material needs to be re-calculated
  7841. */
  7842. get isDirty(): boolean;
  7843. /**
  7844. * Marks the material to indicate that it has been re-calculated
  7845. */
  7846. markAsProcessed(): void;
  7847. /**
  7848. * Marks the material to indicate that it needs to be re-calculated
  7849. */
  7850. markAsUnprocessed(): void;
  7851. /**
  7852. * Marks the material to indicate all of its defines need to be re-calculated
  7853. */
  7854. markAllAsDirty(): void;
  7855. /**
  7856. * Marks the material to indicate that image processing needs to be re-calculated
  7857. */
  7858. markAsImageProcessingDirty(): void;
  7859. /**
  7860. * Marks the material to indicate the lights need to be re-calculated
  7861. * @param disposed Defines whether the light is dirty due to dispose or not
  7862. */
  7863. markAsLightDirty(disposed?: boolean): void;
  7864. /**
  7865. * Marks the attribute state as changed
  7866. */
  7867. markAsAttributesDirty(): void;
  7868. /**
  7869. * Marks the texture state as changed
  7870. */
  7871. markAsTexturesDirty(): void;
  7872. /**
  7873. * Marks the fresnel state as changed
  7874. */
  7875. markAsFresnelDirty(): void;
  7876. /**
  7877. * Marks the misc state as changed
  7878. */
  7879. markAsMiscDirty(): void;
  7880. /**
  7881. * Rebuilds the material defines
  7882. */
  7883. rebuild(): void;
  7884. /**
  7885. * Specifies if two material defines are equal
  7886. * @param other - A material define instance to compare to
  7887. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7888. */
  7889. isEqual(other: MaterialDefines): boolean;
  7890. /**
  7891. * Clones this instance's defines to another instance
  7892. * @param other - material defines to clone values to
  7893. */
  7894. cloneTo(other: MaterialDefines): void;
  7895. /**
  7896. * Resets the material define values
  7897. */
  7898. reset(): void;
  7899. /**
  7900. * Converts the material define values to a string
  7901. * @returns - String of material define information
  7902. */
  7903. toString(): string;
  7904. }
  7905. }
  7906. declare module BABYLON {
  7907. /**
  7908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7910. * 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;
  7911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7912. */
  7913. export class ColorCurves {
  7914. private _dirty;
  7915. private _tempColor;
  7916. private _globalCurve;
  7917. private _highlightsCurve;
  7918. private _midtonesCurve;
  7919. private _shadowsCurve;
  7920. private _positiveCurve;
  7921. private _negativeCurve;
  7922. private _globalHue;
  7923. private _globalDensity;
  7924. private _globalSaturation;
  7925. private _globalExposure;
  7926. /**
  7927. * Gets the global Hue value.
  7928. * 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).
  7929. */
  7930. get globalHue(): number;
  7931. /**
  7932. * Sets the global Hue value.
  7933. * 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).
  7934. */
  7935. set globalHue(value: number);
  7936. /**
  7937. * Gets the global Density value.
  7938. * 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.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get globalDensity(): number;
  7942. /**
  7943. * Sets the global Density value.
  7944. * 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.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. set globalDensity(value: number);
  7948. /**
  7949. * Gets the global Saturation value.
  7950. * 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.
  7951. */
  7952. get globalSaturation(): number;
  7953. /**
  7954. * Sets the global Saturation value.
  7955. * 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.
  7956. */
  7957. set globalSaturation(value: number);
  7958. /**
  7959. * Gets the global Exposure value.
  7960. * 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.
  7961. */
  7962. get globalExposure(): number;
  7963. /**
  7964. * Sets the global Exposure value.
  7965. * 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.
  7966. */
  7967. set globalExposure(value: number);
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * 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).
  7975. */
  7976. get highlightsHue(): number;
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * 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).
  7980. */
  7981. set highlightsHue(value: number);
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * 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.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get highlightsDensity(): number;
  7988. /**
  7989. * Sets the highlights Density value.
  7990. * 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.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. set highlightsDensity(value: number);
  7994. /**
  7995. * Gets the highlights Saturation value.
  7996. * 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.
  7997. */
  7998. get highlightsSaturation(): number;
  7999. /**
  8000. * Sets the highlights Saturation value.
  8001. * 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.
  8002. */
  8003. set highlightsSaturation(value: number);
  8004. /**
  8005. * Gets the highlights Exposure value.
  8006. * 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.
  8007. */
  8008. get highlightsExposure(): number;
  8009. /**
  8010. * Sets the highlights Exposure value.
  8011. * 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.
  8012. */
  8013. set highlightsExposure(value: number);
  8014. private _midtonesHue;
  8015. private _midtonesDensity;
  8016. private _midtonesSaturation;
  8017. private _midtonesExposure;
  8018. /**
  8019. * Gets the midtones Hue value.
  8020. * 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).
  8021. */
  8022. get midtonesHue(): number;
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * 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).
  8026. */
  8027. set midtonesHue(value: number);
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * 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.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get midtonesDensity(): number;
  8034. /**
  8035. * Sets the midtones Density value.
  8036. * 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.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. set midtonesDensity(value: number);
  8040. /**
  8041. * Gets the midtones Saturation value.
  8042. * 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.
  8043. */
  8044. get midtonesSaturation(): number;
  8045. /**
  8046. * Sets the midtones Saturation value.
  8047. * 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.
  8048. */
  8049. set midtonesSaturation(value: number);
  8050. /**
  8051. * Gets the midtones Exposure value.
  8052. * 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.
  8053. */
  8054. get midtonesExposure(): number;
  8055. /**
  8056. * Sets the midtones Exposure value.
  8057. * 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.
  8058. */
  8059. set midtonesExposure(value: number);
  8060. private _shadowsHue;
  8061. private _shadowsDensity;
  8062. private _shadowsSaturation;
  8063. private _shadowsExposure;
  8064. /**
  8065. * Gets the shadows Hue value.
  8066. * 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).
  8067. */
  8068. get shadowsHue(): number;
  8069. /**
  8070. * Sets the shadows Hue value.
  8071. * 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).
  8072. */
  8073. set shadowsHue(value: number);
  8074. /**
  8075. * Gets the shadows Density value.
  8076. * 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.
  8077. * Values less than zero provide a filter of opposite hue.
  8078. */
  8079. get shadowsDensity(): number;
  8080. /**
  8081. * Sets the shadows Density value.
  8082. * 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.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. set shadowsDensity(value: number);
  8086. /**
  8087. * Gets the shadows Saturation value.
  8088. * 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.
  8089. */
  8090. get shadowsSaturation(): number;
  8091. /**
  8092. * Sets the shadows Saturation value.
  8093. * 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.
  8094. */
  8095. set shadowsSaturation(value: number);
  8096. /**
  8097. * Gets the shadows Exposure value.
  8098. * 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.
  8099. */
  8100. get shadowsExposure(): number;
  8101. /**
  8102. * Sets the shadows Exposure value.
  8103. * 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.
  8104. */
  8105. set shadowsExposure(value: number);
  8106. /**
  8107. * Returns the class name
  8108. * @returns The class name
  8109. */
  8110. getClassName(): string;
  8111. /**
  8112. * Binds the color curves to the shader.
  8113. * @param colorCurves The color curve to bind
  8114. * @param effect The effect to bind to
  8115. * @param positiveUniform The positive uniform shader parameter
  8116. * @param neutralUniform The neutral uniform shader parameter
  8117. * @param negativeUniform The negative uniform shader parameter
  8118. */
  8119. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8120. /**
  8121. * Prepare the list of uniforms associated with the ColorCurves effects.
  8122. * @param uniformsList The list of uniforms used in the effect
  8123. */
  8124. static PrepareUniforms(uniformsList: string[]): void;
  8125. /**
  8126. * Returns color grading data based on a hue, density, saturation and exposure value.
  8127. * @param filterHue The hue of the color filter.
  8128. * @param filterDensity The density of the color filter.
  8129. * @param saturation The saturation.
  8130. * @param exposure The exposure.
  8131. * @param result The result data container.
  8132. */
  8133. private getColorGradingDataToRef;
  8134. /**
  8135. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8136. * @param value The input slider value in range [-100,100].
  8137. * @returns Adjusted value.
  8138. */
  8139. private static applyColorGradingSliderNonlinear;
  8140. /**
  8141. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8142. * @param hue The hue (H) input.
  8143. * @param saturation The saturation (S) input.
  8144. * @param brightness The brightness (B) input.
  8145. * @result An RGBA color represented as Vector4.
  8146. */
  8147. private static fromHSBToRef;
  8148. /**
  8149. * Returns a value clamped between min and max
  8150. * @param value The value to clamp
  8151. * @param min The minimum of value
  8152. * @param max The maximum of value
  8153. * @returns The clamped value.
  8154. */
  8155. private static clamp;
  8156. /**
  8157. * Clones the current color curve instance.
  8158. * @return The cloned curves
  8159. */
  8160. clone(): ColorCurves;
  8161. /**
  8162. * Serializes the current color curve instance to a json representation.
  8163. * @return a JSON representation
  8164. */
  8165. serialize(): any;
  8166. /**
  8167. * Parses the color curve from a json representation.
  8168. * @param source the JSON source to parse
  8169. * @return The parsed curves
  8170. */
  8171. static Parse(source: any): ColorCurves;
  8172. }
  8173. }
  8174. declare module BABYLON {
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. get colorCurvesEnabled(): boolean;
  8240. /**
  8241. * Sets wether the color curves effect is enabled.
  8242. */
  8243. set colorCurvesEnabled(value: boolean);
  8244. private _colorGradingTexture;
  8245. /**
  8246. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8247. */
  8248. get colorGradingTexture(): Nullable<BaseTexture>;
  8249. /**
  8250. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8251. */
  8252. set colorGradingTexture(value: Nullable<BaseTexture>);
  8253. private _colorGradingEnabled;
  8254. /**
  8255. * Gets wether the color grading effect is enabled.
  8256. */
  8257. get colorGradingEnabled(): boolean;
  8258. /**
  8259. * Sets wether the color grading effect is enabled.
  8260. */
  8261. set colorGradingEnabled(value: boolean);
  8262. private _colorGradingWithGreenDepth;
  8263. /**
  8264. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. get colorGradingWithGreenDepth(): boolean;
  8267. /**
  8268. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8269. */
  8270. set colorGradingWithGreenDepth(value: boolean);
  8271. private _colorGradingBGR;
  8272. /**
  8273. * Gets wether the color grading texture contains BGR values.
  8274. */
  8275. get colorGradingBGR(): boolean;
  8276. /**
  8277. * Sets wether the color grading texture contains BGR values.
  8278. */
  8279. set colorGradingBGR(value: boolean);
  8280. /** @hidden */
  8281. _exposure: number;
  8282. /**
  8283. * Gets the Exposure used in the effect.
  8284. */
  8285. get exposure(): number;
  8286. /**
  8287. * Sets the Exposure used in the effect.
  8288. */
  8289. set exposure(value: number);
  8290. private _toneMappingEnabled;
  8291. /**
  8292. * Gets wether the tone mapping effect is enabled.
  8293. */
  8294. get toneMappingEnabled(): boolean;
  8295. /**
  8296. * Sets wether the tone mapping effect is enabled.
  8297. */
  8298. set toneMappingEnabled(value: boolean);
  8299. private _toneMappingType;
  8300. /**
  8301. * Gets the type of tone mapping effect.
  8302. */
  8303. get toneMappingType(): number;
  8304. /**
  8305. * Sets the type of tone mapping effect used in BabylonJS.
  8306. */
  8307. set toneMappingType(value: number);
  8308. protected _contrast: number;
  8309. /**
  8310. * Gets the contrast used in the effect.
  8311. */
  8312. get contrast(): number;
  8313. /**
  8314. * Sets the contrast used in the effect.
  8315. */
  8316. set contrast(value: number);
  8317. /**
  8318. * Vignette stretch size.
  8319. */
  8320. vignetteStretch: number;
  8321. /**
  8322. * Vignette centre X Offset.
  8323. */
  8324. vignetteCentreX: number;
  8325. /**
  8326. * Vignette centre Y Offset.
  8327. */
  8328. vignetteCentreY: number;
  8329. /**
  8330. * Vignette weight or intensity of the vignette effect.
  8331. */
  8332. vignetteWeight: number;
  8333. /**
  8334. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8335. * if vignetteEnabled is set to true.
  8336. */
  8337. vignetteColor: Color4;
  8338. /**
  8339. * Camera field of view used by the Vignette effect.
  8340. */
  8341. vignetteCameraFov: number;
  8342. private _vignetteBlendMode;
  8343. /**
  8344. * Gets the vignette blend mode allowing different kind of effect.
  8345. */
  8346. get vignetteBlendMode(): number;
  8347. /**
  8348. * Sets the vignette blend mode allowing different kind of effect.
  8349. */
  8350. set vignetteBlendMode(value: number);
  8351. private _vignetteEnabled;
  8352. /**
  8353. * Gets wether the vignette effect is enabled.
  8354. */
  8355. get vignetteEnabled(): boolean;
  8356. /**
  8357. * Sets wether the vignette effect is enabled.
  8358. */
  8359. set vignetteEnabled(value: boolean);
  8360. private _applyByPostProcess;
  8361. /**
  8362. * Gets wether the image processing is applied through a post process or not.
  8363. */
  8364. get applyByPostProcess(): boolean;
  8365. /**
  8366. * Sets wether the image processing is applied through a post process or not.
  8367. */
  8368. set applyByPostProcess(value: boolean);
  8369. private _isEnabled;
  8370. /**
  8371. * Gets wether the image processing is enabled or not.
  8372. */
  8373. get isEnabled(): boolean;
  8374. /**
  8375. * Sets wether the image processing is enabled or not.
  8376. */
  8377. set isEnabled(value: boolean);
  8378. /**
  8379. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8380. */
  8381. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8382. /**
  8383. * Method called each time the image processing information changes requires to recompile the effect.
  8384. */
  8385. protected _updateParameters(): void;
  8386. /**
  8387. * Gets the current class name.
  8388. * @return "ImageProcessingConfiguration"
  8389. */
  8390. getClassName(): string;
  8391. /**
  8392. * Prepare the list of uniforms associated with the Image Processing effects.
  8393. * @param uniforms The list of uniforms used in the effect
  8394. * @param defines the list of defines currently in use
  8395. */
  8396. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8397. /**
  8398. * Prepare the list of samplers associated with the Image Processing effects.
  8399. * @param samplersList The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of defines associated to the shader.
  8405. * @param defines the list of defines to complete
  8406. * @param forPostProcess Define if we are currently in post process mode or not
  8407. */
  8408. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8409. /**
  8410. * Returns true if all the image processing information are ready.
  8411. * @returns True if ready, otherwise, false
  8412. */
  8413. isReady(): boolean;
  8414. /**
  8415. * Binds the image processing to the shader.
  8416. * @param effect The effect to bind to
  8417. * @param overrideAspectRatio Override the aspect ratio of the effect
  8418. */
  8419. bind(effect: Effect, overrideAspectRatio?: number): void;
  8420. /**
  8421. * Clones the current image processing instance.
  8422. * @return The cloned image processing
  8423. */
  8424. clone(): ImageProcessingConfiguration;
  8425. /**
  8426. * Serializes the current image processing instance to a json representation.
  8427. * @return a JSON representation
  8428. */
  8429. serialize(): any;
  8430. /**
  8431. * Parses the image processing from a json representation.
  8432. * @param source the JSON source to parse
  8433. * @return The parsed image processing
  8434. */
  8435. static Parse(source: any): ImageProcessingConfiguration;
  8436. private static _VIGNETTEMODE_MULTIPLY;
  8437. private static _VIGNETTEMODE_OPAQUE;
  8438. /**
  8439. * Used to apply the vignette as a mix with the pixel color.
  8440. */
  8441. static get VIGNETTEMODE_MULTIPLY(): number;
  8442. /**
  8443. * Used to apply the vignette as a replacement of the pixel color.
  8444. */
  8445. static get VIGNETTEMODE_OPAQUE(): number;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /** @hidden */
  8450. export var postprocessVertexShader: {
  8451. name: string;
  8452. shader: string;
  8453. };
  8454. }
  8455. declare module BABYLON {
  8456. interface ThinEngine {
  8457. /**
  8458. * Creates a new render target texture
  8459. * @param size defines the size of the texture
  8460. * @param options defines the options used to create the texture
  8461. * @returns a new render target texture stored in an InternalTexture
  8462. */
  8463. createRenderTargetTexture(size: number | {
  8464. width: number;
  8465. height: number;
  8466. layers?: number;
  8467. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8468. /**
  8469. * Creates a depth stencil texture.
  8470. * This is only available in WebGL 2 or with the depth texture extension available.
  8471. * @param size The size of face edge in the texture.
  8472. * @param options The options defining the texture.
  8473. * @returns The texture
  8474. */
  8475. createDepthStencilTexture(size: number | {
  8476. width: number;
  8477. height: number;
  8478. layers?: number;
  8479. }, options: DepthTextureCreationOptions): InternalTexture;
  8480. /** @hidden */
  8481. _createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. }
  8487. }
  8488. declare module BABYLON {
  8489. /** Defines supported spaces */
  8490. export enum Space {
  8491. /** Local (object) space */
  8492. LOCAL = 0,
  8493. /** World space */
  8494. WORLD = 1,
  8495. /** Bone space */
  8496. BONE = 2
  8497. }
  8498. /** Defines the 3 main axes */
  8499. export class Axis {
  8500. /** X axis */
  8501. static X: Vector3;
  8502. /** Y axis */
  8503. static Y: Vector3;
  8504. /** Z axis */
  8505. static Z: Vector3;
  8506. }
  8507. }
  8508. declare module BABYLON {
  8509. /**
  8510. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8511. * This is the base of the follow, arc rotate cameras and Free camera
  8512. * @see http://doc.babylonjs.com/features/cameras
  8513. */
  8514. export class TargetCamera extends Camera {
  8515. private static _RigCamTransformMatrix;
  8516. private static _TargetTransformMatrix;
  8517. private static _TargetFocalPoint;
  8518. /**
  8519. * Define the current direction the camera is moving to
  8520. */
  8521. cameraDirection: Vector3;
  8522. /**
  8523. * Define the current rotation the camera is rotating to
  8524. */
  8525. cameraRotation: Vector2;
  8526. /**
  8527. * When set, the up vector of the camera will be updated by the rotation of the camera
  8528. */
  8529. updateUpVectorFromRotation: boolean;
  8530. private _tmpQuaternion;
  8531. /**
  8532. * Define the current rotation of the camera
  8533. */
  8534. rotation: Vector3;
  8535. /**
  8536. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8537. */
  8538. rotationQuaternion: Quaternion;
  8539. /**
  8540. * Define the current speed of the camera
  8541. */
  8542. speed: number;
  8543. /**
  8544. * Add constraint to the camera to prevent it to move freely in all directions and
  8545. * around all axis.
  8546. */
  8547. noRotationConstraint: boolean;
  8548. /**
  8549. * Define the current target of the camera as an object or a position.
  8550. */
  8551. lockedTarget: any;
  8552. /** @hidden */
  8553. _currentTarget: Vector3;
  8554. /** @hidden */
  8555. _initialFocalDistance: number;
  8556. /** @hidden */
  8557. _viewMatrix: Matrix;
  8558. /** @hidden */
  8559. _camMatrix: Matrix;
  8560. /** @hidden */
  8561. _cameraTransformMatrix: Matrix;
  8562. /** @hidden */
  8563. _cameraRotationMatrix: Matrix;
  8564. /** @hidden */
  8565. _referencePoint: Vector3;
  8566. /** @hidden */
  8567. _transformedReferencePoint: Vector3;
  8568. protected _globalCurrentTarget: Vector3;
  8569. protected _globalCurrentUpVector: Vector3;
  8570. /** @hidden */
  8571. _reset: () => void;
  8572. private _defaultUp;
  8573. /**
  8574. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8575. * This is the base of the follow, arc rotate cameras and Free camera
  8576. * @see http://doc.babylonjs.com/features/cameras
  8577. * @param name Defines the name of the camera in the scene
  8578. * @param position Defines the start position of the camera in the scene
  8579. * @param scene Defines the scene the camera belongs to
  8580. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8581. */
  8582. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8583. /**
  8584. * Gets the position in front of the camera at a given distance.
  8585. * @param distance The distance from the camera we want the position to be
  8586. * @returns the position
  8587. */
  8588. getFrontPosition(distance: number): Vector3;
  8589. /** @hidden */
  8590. _getLockedTargetPosition(): Nullable<Vector3>;
  8591. private _storedPosition;
  8592. private _storedRotation;
  8593. private _storedRotationQuaternion;
  8594. /**
  8595. * Store current camera state of the camera (fov, position, rotation, etc..)
  8596. * @returns the camera
  8597. */
  8598. storeState(): Camera;
  8599. /**
  8600. * Restored camera state. You must call storeState() first
  8601. * @returns whether it was successful or not
  8602. * @hidden
  8603. */
  8604. _restoreStateValues(): boolean;
  8605. /** @hidden */
  8606. _initCache(): void;
  8607. /** @hidden */
  8608. _updateCache(ignoreParentClass?: boolean): void;
  8609. /** @hidden */
  8610. _isSynchronizedViewMatrix(): boolean;
  8611. /** @hidden */
  8612. _computeLocalCameraSpeed(): number;
  8613. /**
  8614. * Defines the target the camera should look at.
  8615. * @param target Defines the new target as a Vector or a mesh
  8616. */
  8617. setTarget(target: Vector3): void;
  8618. /**
  8619. * Return the current target position of the camera. This value is expressed in local space.
  8620. * @returns the target position
  8621. */
  8622. getTarget(): Vector3;
  8623. /** @hidden */
  8624. _decideIfNeedsToMove(): boolean;
  8625. /** @hidden */
  8626. _updatePosition(): void;
  8627. /** @hidden */
  8628. _checkInputs(): void;
  8629. protected _updateCameraRotationMatrix(): void;
  8630. /**
  8631. * 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)
  8632. * @returns the current camera
  8633. */
  8634. private _rotateUpVectorWithCameraRotationMatrix;
  8635. private _cachedRotationZ;
  8636. private _cachedQuaternionRotationZ;
  8637. /** @hidden */
  8638. _getViewMatrix(): Matrix;
  8639. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8640. /**
  8641. * @hidden
  8642. */
  8643. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8644. /**
  8645. * @hidden
  8646. */
  8647. _updateRigCameras(): void;
  8648. private _getRigCamPositionAndTarget;
  8649. /**
  8650. * Gets the current object class name.
  8651. * @return the class name
  8652. */
  8653. getClassName(): string;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Gather the list of keyboard event types as constants.
  8659. */
  8660. export class KeyboardEventTypes {
  8661. /**
  8662. * The keydown event is fired when a key becomes active (pressed).
  8663. */
  8664. static readonly KEYDOWN: number;
  8665. /**
  8666. * The keyup event is fired when a key has been released.
  8667. */
  8668. static readonly KEYUP: number;
  8669. }
  8670. /**
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. */
  8673. export class KeyboardInfo {
  8674. /**
  8675. * Defines the type of event (KeyboardEventTypes)
  8676. */
  8677. type: number;
  8678. /**
  8679. * Defines the related dom event
  8680. */
  8681. event: KeyboardEvent;
  8682. /**
  8683. * Instantiates a new keyboard info.
  8684. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8685. * @param type Defines the type of event (KeyboardEventTypes)
  8686. * @param event Defines the related dom event
  8687. */
  8688. constructor(
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number,
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent);
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8700. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8701. */
  8702. export class KeyboardInfoPre extends KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8713. */
  8714. skipOnPointerObservable: boolean;
  8715. /**
  8716. * Instantiates a new keyboard pre info.
  8717. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8718. * @param type Defines the type of event (KeyboardEventTypes)
  8719. * @param event Defines the related dom event
  8720. */
  8721. constructor(
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number,
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent);
  8730. }
  8731. }
  8732. declare module BABYLON {
  8733. /**
  8734. * Manage the keyboard inputs to control the movement of a free camera.
  8735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8736. */
  8737. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8738. /**
  8739. * Defines the camera the input is attached to.
  8740. */
  8741. camera: FreeCamera;
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8744. */
  8745. keysUp: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8748. */
  8749. keysDown: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8752. */
  8753. keysLeft: number[];
  8754. /**
  8755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8756. */
  8757. keysRight: number[];
  8758. private _keys;
  8759. private _onCanvasBlurObserver;
  8760. private _onKeyboardObserver;
  8761. private _engine;
  8762. private _scene;
  8763. /**
  8764. * Attach the input controls to a specific dom element to get the input from.
  8765. * @param element Defines the element the controls should be listened from
  8766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8767. */
  8768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8769. /**
  8770. * Detach the current controls from the specified dom element.
  8771. * @param element Defines the element to stop listening the inputs from
  8772. */
  8773. detachControl(element: Nullable<HTMLElement>): void;
  8774. /**
  8775. * Update the current camera state depending on the inputs that have been used this frame.
  8776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8777. */
  8778. checkInputs(): void;
  8779. /**
  8780. * Gets the class name of the current intput.
  8781. * @returns the class name
  8782. */
  8783. getClassName(): string;
  8784. /** @hidden */
  8785. _onLostFocus(): void;
  8786. /**
  8787. * Get the friendly name associated with the input class.
  8788. * @returns the input friendly name
  8789. */
  8790. getSimpleName(): string;
  8791. }
  8792. }
  8793. declare module BABYLON {
  8794. /**
  8795. * Interface describing all the common properties and methods a shadow light needs to implement.
  8796. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8797. * as well as binding the different shadow properties to the effects.
  8798. */
  8799. export interface IShadowLight extends Light {
  8800. /**
  8801. * The light id in the scene (used in scene.findLighById for instance)
  8802. */
  8803. id: string;
  8804. /**
  8805. * The position the shdow will be casted from.
  8806. */
  8807. position: Vector3;
  8808. /**
  8809. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8810. */
  8811. direction: Vector3;
  8812. /**
  8813. * The transformed position. Position of the light in world space taking parenting in account.
  8814. */
  8815. transformedPosition: Vector3;
  8816. /**
  8817. * The transformed direction. Direction of the light in world space taking parenting in account.
  8818. */
  8819. transformedDirection: Vector3;
  8820. /**
  8821. * The friendly name of the light in the scene.
  8822. */
  8823. name: string;
  8824. /**
  8825. * Defines the shadow projection clipping minimum z value.
  8826. */
  8827. shadowMinZ: number;
  8828. /**
  8829. * Defines the shadow projection clipping maximum z value.
  8830. */
  8831. shadowMaxZ: number;
  8832. /**
  8833. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8834. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8835. */
  8836. computeTransformedInformation(): boolean;
  8837. /**
  8838. * Gets the scene the light belongs to.
  8839. * @returns The scene
  8840. */
  8841. getScene(): Scene;
  8842. /**
  8843. * Callback defining a custom Projection Matrix Builder.
  8844. * This can be used to override the default projection matrix computation.
  8845. */
  8846. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. /**
  8856. * Gets the current depth scale used in ESM.
  8857. * @returns The scale
  8858. */
  8859. getDepthScale(): number;
  8860. /**
  8861. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8862. * @returns true if a cube texture needs to be use
  8863. */
  8864. needCube(): boolean;
  8865. /**
  8866. * Detects if the projection matrix requires to be recomputed this frame.
  8867. * @returns true if it requires to be recomputed otherwise, false.
  8868. */
  8869. needProjectionMatrixCompute(): boolean;
  8870. /**
  8871. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8872. */
  8873. forceProjectionMatrixCompute(): void;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Gets the minZ used for shadow according to both the scene and the light.
  8882. * @param activeCamera The camera we are returning the min for
  8883. * @returns the depth min z
  8884. */
  8885. getDepthMinZ(activeCamera: Camera): number;
  8886. /**
  8887. * Gets the maxZ used for shadow according to both the scene and the light.
  8888. * @param activeCamera The camera we are returning the max for
  8889. * @returns the depth max z
  8890. */
  8891. getDepthMaxZ(activeCamera: Camera): number;
  8892. }
  8893. /**
  8894. * Base implementation IShadowLight
  8895. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8896. */
  8897. export abstract class ShadowLight extends Light implements IShadowLight {
  8898. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8899. protected _position: Vector3;
  8900. protected _setPosition(value: Vector3): void;
  8901. /**
  8902. * Sets the position the shadow will be casted from. Also use as the light position for both
  8903. * point and spot lights.
  8904. */
  8905. get position(): Vector3;
  8906. /**
  8907. * Sets the position the shadow will be casted from. Also use as the light position for both
  8908. * point and spot lights.
  8909. */
  8910. set position(value: Vector3);
  8911. protected _direction: Vector3;
  8912. protected _setDirection(value: Vector3): void;
  8913. /**
  8914. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8915. * Also use as the light direction on spot and directional lights.
  8916. */
  8917. get direction(): Vector3;
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. set direction(value: Vector3);
  8923. protected _shadowMinZ: number;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. get shadowMinZ(): number;
  8928. /**
  8929. * Sets the shadow projection clipping minimum z value.
  8930. */
  8931. set shadowMinZ(value: number);
  8932. protected _shadowMaxZ: number;
  8933. /**
  8934. * Sets the shadow projection clipping maximum z value.
  8935. */
  8936. get shadowMaxZ(): number;
  8937. /**
  8938. * Gets the shadow projection clipping maximum z value.
  8939. */
  8940. set shadowMaxZ(value: number);
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * The transformed position. Position of the light in world space taking parenting in account.
  8948. */
  8949. transformedPosition: Vector3;
  8950. /**
  8951. * The transformed direction. Direction of the light in world space taking parenting in account.
  8952. */
  8953. transformedDirection: Vector3;
  8954. private _needProjectionMatrixCompute;
  8955. /**
  8956. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8957. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8958. */
  8959. computeTransformedInformation(): boolean;
  8960. /**
  8961. * Return the depth scale used for the shadow map.
  8962. * @returns the depth scale.
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8967. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8968. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8969. */
  8970. getShadowDirection(faceIndex?: number): Vector3;
  8971. /**
  8972. * Returns the ShadowLight absolute position in the World.
  8973. * @returns the position vector in world space
  8974. */
  8975. getAbsolutePosition(): Vector3;
  8976. /**
  8977. * Sets the ShadowLight direction toward the passed target.
  8978. * @param target The point to target in local space
  8979. * @returns the updated ShadowLight direction
  8980. */
  8981. setDirectionToTarget(target: Vector3): Vector3;
  8982. /**
  8983. * Returns the light rotation in euler definition.
  8984. * @returns the x y z rotation in local space.
  8985. */
  8986. getRotation(): Vector3;
  8987. /**
  8988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8989. * @returns true if a cube texture needs to be use
  8990. */
  8991. needCube(): boolean;
  8992. /**
  8993. * Detects if the projection matrix requires to be recomputed this frame.
  8994. * @returns true if it requires to be recomputed otherwise, false.
  8995. */
  8996. needProjectionMatrixCompute(): boolean;
  8997. /**
  8998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8999. */
  9000. forceProjectionMatrixCompute(): void;
  9001. /** @hidden */
  9002. _initCache(): void;
  9003. /** @hidden */
  9004. _isSynchronized(): boolean;
  9005. /**
  9006. * Computes the world matrix of the node
  9007. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9008. * @returns the world matrix
  9009. */
  9010. computeWorldMatrix(force?: boolean): Matrix;
  9011. /**
  9012. * Gets the minZ used for shadow according to both the scene and the light.
  9013. * @param activeCamera The camera we are returning the min for
  9014. * @returns the depth min z
  9015. */
  9016. getDepthMinZ(activeCamera: Camera): number;
  9017. /**
  9018. * Gets the maxZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the max for
  9020. * @returns the depth max z
  9021. */
  9022. getDepthMaxZ(activeCamera: Camera): number;
  9023. /**
  9024. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9025. * @param matrix The materix to updated with the projection information
  9026. * @param viewMatrix The transform matrix of the light
  9027. * @param renderList The list of mesh to render in the map
  9028. * @returns The current light
  9029. */
  9030. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9031. }
  9032. }
  9033. declare module BABYLON {
  9034. /**
  9035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9037. */
  9038. export class EffectFallbacks implements IEffectFallbacks {
  9039. private _defines;
  9040. private _currentRank;
  9041. private _maxRank;
  9042. private _mesh;
  9043. /**
  9044. * Removes the fallback from the bound mesh.
  9045. */
  9046. unBindMesh(): void;
  9047. /**
  9048. * Adds a fallback on the specified property.
  9049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9050. * @param define The name of the define in the shader
  9051. */
  9052. addFallback(rank: number, define: string): void;
  9053. /**
  9054. * Sets the mesh to use CPU skinning when needing to fallback.
  9055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9056. * @param mesh The mesh to use the fallbacks.
  9057. */
  9058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9059. /**
  9060. * Checks to see if more fallbacks are still availible.
  9061. */
  9062. get hasMoreFallbacks(): boolean;
  9063. /**
  9064. * Removes the defines that should be removed when falling back.
  9065. * @param currentDefines defines the current define statements for the shader.
  9066. * @param effect defines the current effect we try to compile
  9067. * @returns The resulting defines with defines of the current rank removed.
  9068. */
  9069. reduce(currentDefines: string, effect: Effect): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * "Static Class" containing the most commonly used helper while dealing with material for
  9075. * rendering purpose.
  9076. *
  9077. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9078. *
  9079. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9080. */
  9081. export class MaterialHelper {
  9082. /**
  9083. * Bind the current view position to an effect.
  9084. * @param effect The effect to be bound
  9085. * @param scene The scene the eyes position is used from
  9086. */
  9087. static BindEyePosition(effect: Effect, scene: Scene): void;
  9088. /**
  9089. * Helps preparing the defines values about the UVs in used in the effect.
  9090. * UVs are shared as much as we can accross channels in the shaders.
  9091. * @param texture The texture we are preparing the UVs for
  9092. * @param defines The defines to update
  9093. * @param key The channel key "diffuse", "specular"... used in the shader
  9094. */
  9095. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9096. /**
  9097. * Binds a texture matrix value to its corrsponding uniform
  9098. * @param texture The texture to bind the matrix for
  9099. * @param uniformBuffer The uniform buffer receivin the data
  9100. * @param key The channel key "diffuse", "specular"... used in the shader
  9101. */
  9102. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9103. /**
  9104. * Gets the current status of the fog (should it be enabled?)
  9105. * @param mesh defines the mesh to evaluate for fog support
  9106. * @param scene defines the hosting scene
  9107. * @returns true if fog must be enabled
  9108. */
  9109. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9110. /**
  9111. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9112. * @param mesh defines the current mesh
  9113. * @param scene defines the current scene
  9114. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9115. * @param pointsCloud defines if point cloud rendering has to be turned on
  9116. * @param fogEnabled defines if fog has to be turned on
  9117. * @param alphaTest defines if alpha testing has to be turned on
  9118. * @param defines defines the current list of defines
  9119. */
  9120. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9123. * @param scene defines the current scene
  9124. * @param engine defines the current engine
  9125. * @param defines specifies the list of active defines
  9126. * @param useInstances defines if instances have to be turned on
  9127. * @param useClipPlane defines if clip plane have to be turned on
  9128. */
  9129. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9130. /**
  9131. * Prepares the defines for bones
  9132. * @param mesh The mesh containing the geometry data we will draw
  9133. * @param defines The defines to update
  9134. */
  9135. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9136. /**
  9137. * Prepares the defines for morph targets
  9138. * @param mesh The mesh containing the geometry data we will draw
  9139. * @param defines The defines to update
  9140. */
  9141. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9142. /**
  9143. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9144. * @param mesh The mesh containing the geometry data we will draw
  9145. * @param defines The defines to update
  9146. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9147. * @param useBones Precise whether bones should be used or not (override mesh info)
  9148. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9149. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9150. * @returns false if defines are considered not dirty and have not been checked
  9151. */
  9152. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9153. /**
  9154. * Prepares the defines related to multiview
  9155. * @param scene The scene we are intending to draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9159. /**
  9160. * Prepares the defines related to the light information passed in parameter
  9161. * @param scene The scene we are intending to draw
  9162. * @param mesh The mesh the effect is compiling for
  9163. * @param light The light the effect is compiling for
  9164. * @param lightIndex The index of the light
  9165. * @param defines The defines to update
  9166. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9167. * @param state Defines the current state regarding what is needed (normals, etc...)
  9168. */
  9169. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9170. needNormals: boolean;
  9171. needRebuild: boolean;
  9172. shadowEnabled: boolean;
  9173. specularEnabled: boolean;
  9174. lightmapMode: boolean;
  9175. }): void;
  9176. /**
  9177. * Prepares the defines related to the light information passed in parameter
  9178. * @param scene The scene we are intending to draw
  9179. * @param mesh The mesh the effect is compiling for
  9180. * @param defines The defines to update
  9181. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9182. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9183. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9184. * @returns true if normals will be required for the rest of the effect
  9185. */
  9186. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9187. /**
  9188. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9189. * @param lightIndex defines the light index
  9190. * @param uniformsList The uniform list
  9191. * @param samplersList The sampler list
  9192. * @param projectedLightTexture defines if projected texture must be used
  9193. * @param uniformBuffersList defines an optional list of uniform buffers
  9194. */
  9195. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9196. /**
  9197. * Prepares the uniforms and samplers list to be used in the effect
  9198. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9199. * @param samplersList The sampler list
  9200. * @param defines The defines helping in the list generation
  9201. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9202. */
  9203. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9204. /**
  9205. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9206. * @param defines The defines to update while falling back
  9207. * @param fallbacks The authorized effect fallbacks
  9208. * @param maxSimultaneousLights The maximum number of lights allowed
  9209. * @param rank the current rank of the Effect
  9210. * @returns The newly affected rank
  9211. */
  9212. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9213. private static _TmpMorphInfluencers;
  9214. /**
  9215. * Prepares the list of attributes required for morph targets according to the effect defines.
  9216. * @param attribs The current list of supported attribs
  9217. * @param mesh The mesh to prepare the morph targets attributes for
  9218. * @param influencers The number of influencers
  9219. */
  9220. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param defines The current Defines of the effect
  9226. */
  9227. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9228. /**
  9229. * Prepares the list of attributes required for bones according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the bones attributes for
  9232. * @param defines The current Defines of the effect
  9233. * @param fallbacks The current efffect fallback strategy
  9234. */
  9235. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9236. /**
  9237. * Check and prepare the list of attributes required for instances according to the effect defines.
  9238. * @param attribs The current list of supported attribs
  9239. * @param defines The current MaterialDefines of the effect
  9240. */
  9241. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9242. /**
  9243. * Add the list of attributes required for instances to the attribs array.
  9244. * @param attribs The current list of supported attribs
  9245. */
  9246. static PushAttributesForInstances(attribs: string[]): void;
  9247. /**
  9248. * Binds the light information to the effect.
  9249. * @param light The light containing the generator
  9250. * @param effect The effect we are binding the data to
  9251. * @param lightIndex The light index in the effect used to render
  9252. */
  9253. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9254. /**
  9255. * Binds the lights information from the scene to the effect for the given mesh.
  9256. * @param light Light to bind
  9257. * @param lightIndex Light index
  9258. * @param scene The scene where the light belongs to
  9259. * @param effect The effect we are binding the data to
  9260. * @param useSpecular Defines if specular is supported
  9261. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9262. */
  9263. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9264. /**
  9265. * Binds the lights information from the scene to the effect for the given mesh.
  9266. * @param scene The scene the lights belongs to
  9267. * @param mesh The mesh we are binding the information to render
  9268. * @param effect The effect we are binding the data to
  9269. * @param defines The generated defines for the effect
  9270. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9271. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9272. */
  9273. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9274. private static _tempFogColor;
  9275. /**
  9276. * Binds the fog information from the scene to the effect for the given mesh.
  9277. * @param scene The scene the lights belongs to
  9278. * @param mesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. * @param linearSpace Defines if the fog effect is applied in linear space
  9281. */
  9282. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9283. /**
  9284. * Binds the bones information from the mesh to the effect.
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9289. /**
  9290. * Binds the morph targets information from the mesh to the effect.
  9291. * @param abstractMesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. */
  9294. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9295. /**
  9296. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9297. * @param defines The generated defines used in the effect
  9298. * @param effect The effect we are binding the data to
  9299. * @param scene The scene we are willing to render with logarithmic scale for
  9300. */
  9301. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9302. /**
  9303. * Binds the clip plane information from the scene to the effect.
  9304. * @param scene The scene the clip plane information are extracted from
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindClipPlane(effect: Effect, scene: Scene): void;
  9308. }
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var packingFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var clipPlaneFragmentDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var clipPlaneFragment: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var clipPlaneVertexDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var bonesVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var shadowMapVertexShader: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var depthBoxBlurPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * Class representing a ray with position and direction
  9425. */
  9426. export class Ray {
  9427. /** origin point */
  9428. origin: Vector3;
  9429. /** direction */
  9430. direction: Vector3;
  9431. /** length of the ray */
  9432. length: number;
  9433. private static readonly TmpVector3;
  9434. private _tmpRay;
  9435. /**
  9436. * Creates a new ray
  9437. * @param origin origin point
  9438. * @param direction direction
  9439. * @param length length of the ray
  9440. */
  9441. constructor(
  9442. /** origin point */
  9443. origin: Vector3,
  9444. /** direction */
  9445. direction: Vector3,
  9446. /** length of the ray */
  9447. length?: number);
  9448. /**
  9449. * Checks if the ray intersects a box
  9450. * @param minimum bound of the box
  9451. * @param maximum bound of the box
  9452. * @param intersectionTreshold extra extend to be added to the box in all direction
  9453. * @returns if the box was hit
  9454. */
  9455. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9456. /**
  9457. * Checks if the ray intersects a box
  9458. * @param box the bounding box to check
  9459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9460. * @returns if the box was hit
  9461. */
  9462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9463. /**
  9464. * If the ray hits a sphere
  9465. * @param sphere the bounding sphere to check
  9466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9467. * @returns true if it hits the sphere
  9468. */
  9469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9470. /**
  9471. * If the ray hits a triange
  9472. * @param vertex0 triangle vertex
  9473. * @param vertex1 triangle vertex
  9474. * @param vertex2 triangle vertex
  9475. * @returns intersection information if hit
  9476. */
  9477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9478. /**
  9479. * Checks if ray intersects a plane
  9480. * @param plane the plane to check
  9481. * @returns the distance away it was hit
  9482. */
  9483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9484. /**
  9485. * Calculate the intercept of a ray on a given axis
  9486. * @param axis to check 'x' | 'y' | 'z'
  9487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9489. */
  9490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9491. /**
  9492. * Checks if ray intersects a mesh
  9493. * @param mesh the mesh to check
  9494. * @param fastCheck if only the bounding box should checked
  9495. * @returns picking info of the intersecton
  9496. */
  9497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9498. /**
  9499. * Checks if ray intersects a mesh
  9500. * @param meshes the meshes to check
  9501. * @param fastCheck if only the bounding box should checked
  9502. * @param results array to store result in
  9503. * @returns Array of picking infos
  9504. */
  9505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9506. private _comparePickingInfo;
  9507. private static smallnum;
  9508. private static rayl;
  9509. /**
  9510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9511. * @param sega the first point of the segment to test the intersection against
  9512. * @param segb the second point of the segment to test the intersection against
  9513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9515. */
  9516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9517. /**
  9518. * Update the ray from viewport position
  9519. * @param x position
  9520. * @param y y position
  9521. * @param viewportWidth viewport width
  9522. * @param viewportHeight viewport height
  9523. * @param world world matrix
  9524. * @param view view matrix
  9525. * @param projection projection matrix
  9526. * @returns this ray updated
  9527. */
  9528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9529. /**
  9530. * Creates a ray with origin and direction of 0,0,0
  9531. * @returns the new ray
  9532. */
  9533. static Zero(): Ray;
  9534. /**
  9535. * Creates a new ray from screen space and viewport
  9536. * @param x position
  9537. * @param y y position
  9538. * @param viewportWidth viewport width
  9539. * @param viewportHeight viewport height
  9540. * @param world world matrix
  9541. * @param view view matrix
  9542. * @param projection projection matrix
  9543. * @returns new ray
  9544. */
  9545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9546. /**
  9547. * 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
  9548. * transformed to the given world matrix.
  9549. * @param origin The origin point
  9550. * @param end The end point
  9551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9552. * @returns the new ray
  9553. */
  9554. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9555. /**
  9556. * Transforms a ray by a matrix
  9557. * @param ray ray to transform
  9558. * @param matrix matrix to apply
  9559. * @returns the resulting new ray
  9560. */
  9561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9562. /**
  9563. * Transforms a ray by a matrix
  9564. * @param ray ray to transform
  9565. * @param matrix matrix to apply
  9566. * @param result ray to store result in
  9567. */
  9568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9569. /**
  9570. * Unproject a ray from screen space to object space
  9571. * @param sourceX defines the screen space x coordinate to use
  9572. * @param sourceY defines the screen space y coordinate to use
  9573. * @param viewportWidth defines the current width of the viewport
  9574. * @param viewportHeight defines the current height of the viewport
  9575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9576. * @param view defines the view matrix to use
  9577. * @param projection defines the projection matrix to use
  9578. */
  9579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9580. }
  9581. /**
  9582. * Type used to define predicate used to select faces when a mesh intersection is detected
  9583. */
  9584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9585. interface Scene {
  9586. /** @hidden */
  9587. _tempPickingRay: Nullable<Ray>;
  9588. /** @hidden */
  9589. _cachedRayForTransform: Ray;
  9590. /** @hidden */
  9591. _pickWithRayInverseMatrix: Matrix;
  9592. /** @hidden */
  9593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9594. /** @hidden */
  9595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9596. }
  9597. }
  9598. declare module BABYLON {
  9599. /**
  9600. * Groups all the scene component constants in one place to ease maintenance.
  9601. * @hidden
  9602. */
  9603. export class SceneComponentConstants {
  9604. static readonly NAME_EFFECTLAYER: string;
  9605. static readonly NAME_LAYER: string;
  9606. static readonly NAME_LENSFLARESYSTEM: string;
  9607. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9608. static readonly NAME_PARTICLESYSTEM: string;
  9609. static readonly NAME_GAMEPAD: string;
  9610. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9611. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9612. static readonly NAME_DEPTHRENDERER: string;
  9613. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9614. static readonly NAME_SPRITE: string;
  9615. static readonly NAME_OUTLINERENDERER: string;
  9616. static readonly NAME_PROCEDURALTEXTURE: string;
  9617. static readonly NAME_SHADOWGENERATOR: string;
  9618. static readonly NAME_OCTREE: string;
  9619. static readonly NAME_PHYSICSENGINE: string;
  9620. static readonly NAME_AUDIO: string;
  9621. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9622. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9623. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9624. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9625. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9626. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9627. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9641. static readonly STEP_AFTERRENDER_AUDIO: number;
  9642. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9643. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9644. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9645. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9646. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9647. static readonly STEP_POINTERMOVE_SPRITE: number;
  9648. static readonly STEP_POINTERDOWN_SPRITE: number;
  9649. static readonly STEP_POINTERUP_SPRITE: number;
  9650. }
  9651. /**
  9652. * This represents a scene component.
  9653. *
  9654. * This is used to decouple the dependency the scene is having on the different workloads like
  9655. * layers, post processes...
  9656. */
  9657. export interface ISceneComponent {
  9658. /**
  9659. * The name of the component. Each component must have a unique name.
  9660. */
  9661. name: string;
  9662. /**
  9663. * The scene the component belongs to.
  9664. */
  9665. scene: Scene;
  9666. /**
  9667. * Register the component to one instance of a scene.
  9668. */
  9669. register(): void;
  9670. /**
  9671. * Rebuilds the elements related to this component in case of
  9672. * context lost for instance.
  9673. */
  9674. rebuild(): void;
  9675. /**
  9676. * Disposes the component and the associated ressources.
  9677. */
  9678. dispose(): void;
  9679. }
  9680. /**
  9681. * This represents a SERIALIZABLE scene component.
  9682. *
  9683. * This extends Scene Component to add Serialization methods on top.
  9684. */
  9685. export interface ISceneSerializableComponent extends ISceneComponent {
  9686. /**
  9687. * Adds all the elements from the container to the scene
  9688. * @param container the container holding the elements
  9689. */
  9690. addFromContainer(container: AbstractScene): void;
  9691. /**
  9692. * Removes all the elements in the container from the scene
  9693. * @param container contains the elements to remove
  9694. * @param dispose if the removed element should be disposed (default: false)
  9695. */
  9696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9697. /**
  9698. * Serializes the component data to the specified json object
  9699. * @param serializationObject The object to serialize to
  9700. */
  9701. serialize(serializationObject: any): void;
  9702. }
  9703. /**
  9704. * Strong typing of a Mesh related stage step action
  9705. */
  9706. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9707. /**
  9708. * Strong typing of a Evaluate Sub Mesh related stage step action
  9709. */
  9710. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9711. /**
  9712. * Strong typing of a Active Mesh related stage step action
  9713. */
  9714. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9715. /**
  9716. * Strong typing of a Camera related stage step action
  9717. */
  9718. export type CameraStageAction = (camera: Camera) => void;
  9719. /**
  9720. * Strong typing of a Camera Frame buffer related stage step action
  9721. */
  9722. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9723. /**
  9724. * Strong typing of a Render Target related stage step action
  9725. */
  9726. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9727. /**
  9728. * Strong typing of a RenderingGroup related stage step action
  9729. */
  9730. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9731. /**
  9732. * Strong typing of a Mesh Render related stage step action
  9733. */
  9734. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9735. /**
  9736. * Strong typing of a simple stage step action
  9737. */
  9738. export type SimpleStageAction = () => void;
  9739. /**
  9740. * Strong typing of a render target action.
  9741. */
  9742. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9743. /**
  9744. * Strong typing of a pointer move action.
  9745. */
  9746. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9747. /**
  9748. * Strong typing of a pointer up/down action.
  9749. */
  9750. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9751. /**
  9752. * Representation of a stage in the scene (Basically a list of ordered steps)
  9753. * @hidden
  9754. */
  9755. export class Stage<T extends Function> extends Array<{
  9756. index: number;
  9757. component: ISceneComponent;
  9758. action: T;
  9759. }> {
  9760. /**
  9761. * Hide ctor from the rest of the world.
  9762. * @param items The items to add.
  9763. */
  9764. private constructor();
  9765. /**
  9766. * Creates a new Stage.
  9767. * @returns A new instance of a Stage
  9768. */
  9769. static Create<T extends Function>(): Stage<T>;
  9770. /**
  9771. * Registers a step in an ordered way in the targeted stage.
  9772. * @param index Defines the position to register the step in
  9773. * @param component Defines the component attached to the step
  9774. * @param action Defines the action to launch during the step
  9775. */
  9776. registerStep(index: number, component: ISceneComponent, action: T): void;
  9777. /**
  9778. * Clears all the steps from the stage.
  9779. */
  9780. clear(): void;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. interface Scene {
  9785. /** @hidden */
  9786. _pointerOverSprite: Nullable<Sprite>;
  9787. /** @hidden */
  9788. _pickedDownSprite: Nullable<Sprite>;
  9789. /** @hidden */
  9790. _tempSpritePickingRay: Nullable<Ray>;
  9791. /**
  9792. * All of the sprite managers added to this scene
  9793. * @see http://doc.babylonjs.com/babylon101/sprites
  9794. */
  9795. spriteManagers: Array<ISpriteManager>;
  9796. /**
  9797. * An event triggered when sprites rendering is about to start
  9798. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9799. */
  9800. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9801. /**
  9802. * An event triggered when sprites rendering is done
  9803. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9804. */
  9805. onAfterSpritesRenderingObservable: Observable<Scene>;
  9806. /** @hidden */
  9807. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9808. /** Launch a ray to try to pick a sprite in the scene
  9809. * @param x position on screen
  9810. * @param y position on screen
  9811. * @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
  9812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9813. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9814. * @returns a PickingInfo
  9815. */
  9816. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9817. /** Use the given ray to pick a sprite in the scene
  9818. * @param ray The ray (in world space) to use to pick meshes
  9819. * @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
  9820. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9821. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9822. * @returns a PickingInfo
  9823. */
  9824. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9825. /** @hidden */
  9826. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9827. /** Launch a ray to try to pick sprites in the scene
  9828. * @param x position on screen
  9829. * @param y position on screen
  9830. * @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
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo array
  9833. */
  9834. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9835. /** Use the given ray to pick sprites in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @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
  9838. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9839. * @returns a PickingInfo array
  9840. */
  9841. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9842. /**
  9843. * Force the sprite under the pointer
  9844. * @param sprite defines the sprite to use
  9845. */
  9846. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9847. /**
  9848. * Gets the sprite under the pointer
  9849. * @returns a Sprite or null if no sprite is under the pointer
  9850. */
  9851. getPointerOverSprite(): Nullable<Sprite>;
  9852. }
  9853. /**
  9854. * Defines the sprite scene component responsible to manage sprites
  9855. * in a given scene.
  9856. */
  9857. export class SpriteSceneComponent implements ISceneComponent {
  9858. /**
  9859. * The component name helpfull to identify the component in the list of scene components.
  9860. */
  9861. readonly name: string;
  9862. /**
  9863. * The scene the component belongs to.
  9864. */
  9865. scene: Scene;
  9866. /** @hidden */
  9867. private _spritePredicate;
  9868. /**
  9869. * Creates a new instance of the component for the given scene
  9870. * @param scene Defines the scene to register the component in
  9871. */
  9872. constructor(scene: Scene);
  9873. /**
  9874. * Registers the component in a given scene
  9875. */
  9876. register(): void;
  9877. /**
  9878. * Rebuilds the elements related to this component in case of
  9879. * context lost for instance.
  9880. */
  9881. rebuild(): void;
  9882. /**
  9883. * Disposes the component and the associated ressources.
  9884. */
  9885. dispose(): void;
  9886. private _pickSpriteButKeepRay;
  9887. private _pointerMove;
  9888. private _pointerDown;
  9889. private _pointerUp;
  9890. }
  9891. }
  9892. declare module BABYLON {
  9893. /** @hidden */
  9894. export var fogFragmentDeclaration: {
  9895. name: string;
  9896. shader: string;
  9897. };
  9898. }
  9899. declare module BABYLON {
  9900. /** @hidden */
  9901. export var fogFragment: {
  9902. name: string;
  9903. shader: string;
  9904. };
  9905. }
  9906. declare module BABYLON {
  9907. /** @hidden */
  9908. export var spritesPixelShader: {
  9909. name: string;
  9910. shader: string;
  9911. };
  9912. }
  9913. declare module BABYLON {
  9914. /** @hidden */
  9915. export var fogVertexDeclaration: {
  9916. name: string;
  9917. shader: string;
  9918. };
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var spritesVertexShader: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /**
  9929. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9930. */
  9931. export interface ISpriteManager extends IDisposable {
  9932. /**
  9933. * Restricts the camera to viewing objects with the same layerMask.
  9934. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9935. */
  9936. layerMask: number;
  9937. /**
  9938. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9939. */
  9940. isPickable: boolean;
  9941. /**
  9942. * Specifies the rendering group id for this mesh (0 by default)
  9943. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9944. */
  9945. renderingGroupId: number;
  9946. /**
  9947. * Defines the list of sprites managed by the manager.
  9948. */
  9949. sprites: Array<Sprite>;
  9950. /**
  9951. * Tests the intersection of a sprite with a specific ray.
  9952. * @param ray The ray we are sending to test the collision
  9953. * @param camera The camera space we are sending rays in
  9954. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9955. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9956. * @returns picking info or null.
  9957. */
  9958. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9959. /**
  9960. * Intersects the sprites with a ray
  9961. * @param ray defines the ray to intersect with
  9962. * @param camera defines the current active camera
  9963. * @param predicate defines a predicate used to select candidate sprites
  9964. * @returns null if no hit or a PickingInfo array
  9965. */
  9966. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9967. /**
  9968. * Renders the list of sprites on screen.
  9969. */
  9970. render(): void;
  9971. }
  9972. /**
  9973. * Class used to manage multiple sprites on the same spritesheet
  9974. * @see http://doc.babylonjs.com/babylon101/sprites
  9975. */
  9976. export class SpriteManager implements ISpriteManager {
  9977. /** defines the manager's name */
  9978. name: string;
  9979. /** Gets the list of sprites */
  9980. sprites: Sprite[];
  9981. /** Gets or sets the rendering group id (0 by default) */
  9982. renderingGroupId: number;
  9983. /** Gets or sets camera layer mask */
  9984. layerMask: number;
  9985. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9986. fogEnabled: boolean;
  9987. /** Gets or sets a boolean indicating if the sprites are pickable */
  9988. isPickable: boolean;
  9989. /** Defines the default width of a cell in the spritesheet */
  9990. cellWidth: number;
  9991. /** Defines the default height of a cell in the spritesheet */
  9992. cellHeight: number;
  9993. /** Associative array from JSON sprite data file */
  9994. private _cellData;
  9995. /** Array of sprite names from JSON sprite data file */
  9996. private _spriteMap;
  9997. /** True when packed cell data from JSON file is ready*/
  9998. private _packedAndReady;
  9999. /**
  10000. * An event triggered when the manager is disposed.
  10001. */
  10002. onDisposeObservable: Observable<SpriteManager>;
  10003. private _onDisposeObserver;
  10004. /**
  10005. * Callback called when the manager is disposed
  10006. */
  10007. set onDispose(callback: () => void);
  10008. private _capacity;
  10009. private _fromPacked;
  10010. private _spriteTexture;
  10011. private _epsilon;
  10012. private _scene;
  10013. private _vertexData;
  10014. private _buffer;
  10015. private _vertexBuffers;
  10016. private _indexBuffer;
  10017. private _effectBase;
  10018. private _effectFog;
  10019. /**
  10020. * Gets or sets the spritesheet texture
  10021. */
  10022. get texture(): Texture;
  10023. set texture(value: Texture);
  10024. private _blendMode;
  10025. /**
  10026. * Blend mode use to render the particle, it can be any of
  10027. * the static Constants.ALPHA_x properties provided in this class.
  10028. * Default value is Constants.ALPHA_COMBINE
  10029. */
  10030. get blendMode(): number;
  10031. set blendMode(blendMode: number);
  10032. /**
  10033. * Creates a new sprite manager
  10034. * @param name defines the manager's name
  10035. * @param imgUrl defines the sprite sheet url
  10036. * @param capacity defines the maximum allowed number of sprites
  10037. * @param cellSize defines the size of a sprite cell
  10038. * @param scene defines the hosting scene
  10039. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10040. * @param samplingMode defines the smapling mode to use with spritesheet
  10041. * @param fromPacked set to false; do not alter
  10042. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10043. */
  10044. constructor(
  10045. /** defines the manager's name */
  10046. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10047. private _makePacked;
  10048. private _appendSpriteVertex;
  10049. /**
  10050. * Intersects the sprites with a ray
  10051. * @param ray defines the ray to intersect with
  10052. * @param camera defines the current active camera
  10053. * @param predicate defines a predicate used to select candidate sprites
  10054. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10055. * @returns null if no hit or a PickingInfo
  10056. */
  10057. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10058. /**
  10059. * Intersects the sprites with a ray
  10060. * @param ray defines the ray to intersect with
  10061. * @param camera defines the current active camera
  10062. * @param predicate defines a predicate used to select candidate sprites
  10063. * @returns null if no hit or a PickingInfo array
  10064. */
  10065. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10066. /**
  10067. * Render all child sprites
  10068. */
  10069. render(): void;
  10070. /**
  10071. * Release associated resources
  10072. */
  10073. dispose(): void;
  10074. }
  10075. }
  10076. declare module BABYLON {
  10077. /** Interface used by value gradients (color, factor, ...) */
  10078. export interface IValueGradient {
  10079. /**
  10080. * Gets or sets the gradient value (between 0 and 1)
  10081. */
  10082. gradient: number;
  10083. }
  10084. /** Class used to store color4 gradient */
  10085. export class ColorGradient implements IValueGradient {
  10086. /**
  10087. * Gets or sets the gradient value (between 0 and 1)
  10088. */
  10089. gradient: number;
  10090. /**
  10091. * Gets or sets first associated color
  10092. */
  10093. color1: Color4;
  10094. /**
  10095. * Gets or sets second associated color
  10096. */
  10097. color2?: Color4;
  10098. /**
  10099. * Will get a color picked randomly between color1 and color2.
  10100. * If color2 is undefined then color1 will be used
  10101. * @param result defines the target Color4 to store the result in
  10102. */
  10103. getColorToRef(result: Color4): void;
  10104. }
  10105. /** Class used to store color 3 gradient */
  10106. export class Color3Gradient implements IValueGradient {
  10107. /**
  10108. * Gets or sets the gradient value (between 0 and 1)
  10109. */
  10110. gradient: number;
  10111. /**
  10112. * Gets or sets the associated color
  10113. */
  10114. color: Color3;
  10115. }
  10116. /** Class used to store factor gradient */
  10117. export class FactorGradient implements IValueGradient {
  10118. /**
  10119. * Gets or sets the gradient value (between 0 and 1)
  10120. */
  10121. gradient: number;
  10122. /**
  10123. * Gets or sets first associated factor
  10124. */
  10125. factor1: number;
  10126. /**
  10127. * Gets or sets second associated factor
  10128. */
  10129. factor2?: number;
  10130. /**
  10131. * Will get a number picked randomly between factor1 and factor2.
  10132. * If factor2 is undefined then factor1 will be used
  10133. * @returns the picked number
  10134. */
  10135. getFactor(): number;
  10136. }
  10137. /**
  10138. * Helper used to simplify some generic gradient tasks
  10139. */
  10140. export class GradientHelper {
  10141. /**
  10142. * Gets the current gradient from an array of IValueGradient
  10143. * @param ratio defines the current ratio to get
  10144. * @param gradients defines the array of IValueGradient
  10145. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10146. */
  10147. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10148. }
  10149. }
  10150. declare module BABYLON {
  10151. /**
  10152. * Interface for the size containing width and height
  10153. */
  10154. export interface ISize {
  10155. /**
  10156. * Width
  10157. */
  10158. width: number;
  10159. /**
  10160. * Heighht
  10161. */
  10162. height: number;
  10163. }
  10164. /**
  10165. * Size containing widht and height
  10166. */
  10167. export class Size implements ISize {
  10168. /**
  10169. * Width
  10170. */
  10171. width: number;
  10172. /**
  10173. * Height
  10174. */
  10175. height: number;
  10176. /**
  10177. * Creates a Size object from the given width and height (floats).
  10178. * @param width width of the new size
  10179. * @param height height of the new size
  10180. */
  10181. constructor(width: number, height: number);
  10182. /**
  10183. * Returns a string with the Size width and height
  10184. * @returns a string with the Size width and height
  10185. */
  10186. toString(): string;
  10187. /**
  10188. * "Size"
  10189. * @returns the string "Size"
  10190. */
  10191. getClassName(): string;
  10192. /**
  10193. * Returns the Size hash code.
  10194. * @returns a hash code for a unique width and height
  10195. */
  10196. getHashCode(): number;
  10197. /**
  10198. * Updates the current size from the given one.
  10199. * @param src the given size
  10200. */
  10201. copyFrom(src: Size): void;
  10202. /**
  10203. * Updates in place the current Size from the given floats.
  10204. * @param width width of the new size
  10205. * @param height height of the new size
  10206. * @returns the updated Size.
  10207. */
  10208. copyFromFloats(width: number, height: number): Size;
  10209. /**
  10210. * Updates in place the current Size from the given floats.
  10211. * @param width width to set
  10212. * @param height height to set
  10213. * @returns the updated Size.
  10214. */
  10215. set(width: number, height: number): Size;
  10216. /**
  10217. * Multiplies the width and height by numbers
  10218. * @param w factor to multiple the width by
  10219. * @param h factor to multiple the height by
  10220. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10221. */
  10222. multiplyByFloats(w: number, h: number): Size;
  10223. /**
  10224. * Clones the size
  10225. * @returns a new Size copied from the given one.
  10226. */
  10227. clone(): Size;
  10228. /**
  10229. * True if the current Size and the given one width and height are strictly equal.
  10230. * @param other the other size to compare against
  10231. * @returns True if the current Size and the given one width and height are strictly equal.
  10232. */
  10233. equals(other: Size): boolean;
  10234. /**
  10235. * The surface of the Size : width * height (float).
  10236. */
  10237. get surface(): number;
  10238. /**
  10239. * Create a new size of zero
  10240. * @returns a new Size set to (0.0, 0.0)
  10241. */
  10242. static Zero(): Size;
  10243. /**
  10244. * Sums the width and height of two sizes
  10245. * @param otherSize size to add to this size
  10246. * @returns a new Size set as the addition result of the current Size and the given one.
  10247. */
  10248. add(otherSize: Size): Size;
  10249. /**
  10250. * Subtracts the width and height of two
  10251. * @param otherSize size to subtract to this size
  10252. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10253. */
  10254. subtract(otherSize: Size): Size;
  10255. /**
  10256. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10257. * @param start starting size to lerp between
  10258. * @param end end size to lerp between
  10259. * @param amount amount to lerp between the start and end values
  10260. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10261. */
  10262. static Lerp(start: Size, end: Size, amount: number): Size;
  10263. }
  10264. }
  10265. declare module BABYLON {
  10266. interface ThinEngine {
  10267. /**
  10268. * Creates a dynamic texture
  10269. * @param width defines the width of the texture
  10270. * @param height defines the height of the texture
  10271. * @param generateMipMaps defines if the engine should generate the mip levels
  10272. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10273. * @returns the dynamic texture inside an InternalTexture
  10274. */
  10275. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10276. /**
  10277. * Update the content of a dynamic texture
  10278. * @param texture defines the texture to update
  10279. * @param canvas defines the canvas containing the source
  10280. * @param invertY defines if data must be stored with Y axis inverted
  10281. * @param premulAlpha defines if alpha is stored as premultiplied
  10282. * @param format defines the format of the data
  10283. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10284. */
  10285. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10286. }
  10287. }
  10288. declare module BABYLON {
  10289. /**
  10290. * Helper class used to generate a canvas to manipulate images
  10291. */
  10292. export class CanvasGenerator {
  10293. /**
  10294. * Create a new canvas (or offscreen canvas depending on the context)
  10295. * @param width defines the expected width
  10296. * @param height defines the expected height
  10297. * @return a new canvas or offscreen canvas
  10298. */
  10299. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10300. }
  10301. }
  10302. declare module BABYLON {
  10303. /**
  10304. * A class extending Texture allowing drawing on a texture
  10305. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10306. */
  10307. export class DynamicTexture extends Texture {
  10308. private _generateMipMaps;
  10309. private _canvas;
  10310. private _context;
  10311. private _engine;
  10312. /**
  10313. * Creates a DynamicTexture
  10314. * @param name defines the name of the texture
  10315. * @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
  10316. * @param scene defines the scene where you want the texture
  10317. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10318. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10319. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10320. */
  10321. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10322. /**
  10323. * Get the current class name of the texture useful for serialization or dynamic coding.
  10324. * @returns "DynamicTexture"
  10325. */
  10326. getClassName(): string;
  10327. /**
  10328. * Gets the current state of canRescale
  10329. */
  10330. get canRescale(): boolean;
  10331. private _recreate;
  10332. /**
  10333. * Scales the texture
  10334. * @param ratio the scale factor to apply to both width and height
  10335. */
  10336. scale(ratio: number): void;
  10337. /**
  10338. * Resizes the texture
  10339. * @param width the new width
  10340. * @param height the new height
  10341. */
  10342. scaleTo(width: number, height: number): void;
  10343. /**
  10344. * Gets the context of the canvas used by the texture
  10345. * @returns the canvas context of the dynamic texture
  10346. */
  10347. getContext(): CanvasRenderingContext2D;
  10348. /**
  10349. * Clears the texture
  10350. */
  10351. clear(): void;
  10352. /**
  10353. * Updates the texture
  10354. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10355. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10356. */
  10357. update(invertY?: boolean, premulAlpha?: boolean): void;
  10358. /**
  10359. * Draws text onto the texture
  10360. * @param text defines the text to be drawn
  10361. * @param x defines the placement of the text from the left
  10362. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10363. * @param font defines the font to be used with font-style, font-size, font-name
  10364. * @param color defines the color used for the text
  10365. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10366. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10367. * @param update defines whether texture is immediately update (default is true)
  10368. */
  10369. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10370. /**
  10371. * Clones the texture
  10372. * @returns the clone of the texture.
  10373. */
  10374. clone(): DynamicTexture;
  10375. /**
  10376. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10377. * @returns a serialized dynamic texture object
  10378. */
  10379. serialize(): any;
  10380. /** @hidden */
  10381. _rebuild(): void;
  10382. }
  10383. }
  10384. declare module BABYLON {
  10385. interface Engine {
  10386. /**
  10387. * Creates a raw texture
  10388. * @param data defines the data to store in the texture
  10389. * @param width defines the width of the texture
  10390. * @param height defines the height of the texture
  10391. * @param format defines the format of the data
  10392. * @param generateMipMaps defines if the engine should generate the mip levels
  10393. * @param invertY defines if data must be stored with Y axis inverted
  10394. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10395. * @param compression defines the compression used (null by default)
  10396. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10397. * @returns the raw texture inside an InternalTexture
  10398. */
  10399. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10400. /**
  10401. * Update a raw texture
  10402. * @param texture defines the texture to update
  10403. * @param data defines the data to store in the texture
  10404. * @param format defines the format of the data
  10405. * @param invertY defines if data must be stored with Y axis inverted
  10406. */
  10407. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10408. /**
  10409. * Update a raw texture
  10410. * @param texture defines the texture to update
  10411. * @param data defines the data to store in the texture
  10412. * @param format defines the format of the data
  10413. * @param invertY defines if data must be stored with Y axis inverted
  10414. * @param compression defines the compression used (null by default)
  10415. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10416. */
  10417. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10418. /**
  10419. * Creates a new raw cube texture
  10420. * @param data defines the array of data to use to create each face
  10421. * @param size defines the size of the textures
  10422. * @param format defines the format of the data
  10423. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10424. * @param generateMipMaps defines if the engine should generate the mip levels
  10425. * @param invertY defines if data must be stored with Y axis inverted
  10426. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10427. * @param compression defines the compression used (null by default)
  10428. * @returns the cube texture as an InternalTexture
  10429. */
  10430. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10431. /**
  10432. * Update a raw cube texture
  10433. * @param texture defines the texture to udpdate
  10434. * @param data defines the data to store
  10435. * @param format defines the data format
  10436. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10437. * @param invertY defines if data must be stored with Y axis inverted
  10438. */
  10439. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10440. /**
  10441. * Update a raw cube texture
  10442. * @param texture defines the texture to udpdate
  10443. * @param data defines the data to store
  10444. * @param format defines the data format
  10445. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10446. * @param invertY defines if data must be stored with Y axis inverted
  10447. * @param compression defines the compression used (null by default)
  10448. */
  10449. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10450. /**
  10451. * Update a raw cube texture
  10452. * @param texture defines the texture to udpdate
  10453. * @param data defines the data to store
  10454. * @param format defines the data format
  10455. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10456. * @param invertY defines if data must be stored with Y axis inverted
  10457. * @param compression defines the compression used (null by default)
  10458. * @param level defines which level of the texture to update
  10459. */
  10460. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10461. /**
  10462. * Creates a new raw cube texture from a specified url
  10463. * @param url defines the url where the data is located
  10464. * @param scene defines the current scene
  10465. * @param size defines the size of the textures
  10466. * @param format defines the format of the data
  10467. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10468. * @param noMipmap defines if the engine should avoid generating the mip levels
  10469. * @param callback defines a callback used to extract texture data from loaded data
  10470. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10471. * @param onLoad defines a callback called when texture is loaded
  10472. * @param onError defines a callback called if there is an error
  10473. * @returns the cube texture as an InternalTexture
  10474. */
  10475. 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;
  10476. /**
  10477. * Creates a new raw cube texture from a specified url
  10478. * @param url defines the url where the data is located
  10479. * @param scene defines the current scene
  10480. * @param size defines the size of the textures
  10481. * @param format defines the format of the data
  10482. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10483. * @param noMipmap defines if the engine should avoid generating the mip levels
  10484. * @param callback defines a callback used to extract texture data from loaded data
  10485. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10486. * @param onLoad defines a callback called when texture is loaded
  10487. * @param onError defines a callback called if there is an error
  10488. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10489. * @param invertY defines if data must be stored with Y axis inverted
  10490. * @returns the cube texture as an InternalTexture
  10491. */
  10492. 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;
  10493. /**
  10494. * Creates a new raw 3D texture
  10495. * @param data defines the data used to create the texture
  10496. * @param width defines the width of the texture
  10497. * @param height defines the height of the texture
  10498. * @param depth defines the depth of the texture
  10499. * @param format defines the format of the texture
  10500. * @param generateMipMaps defines if the engine must generate mip levels
  10501. * @param invertY defines if data must be stored with Y axis inverted
  10502. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10503. * @param compression defines the compressed used (can be null)
  10504. * @param textureType defines the compressed used (can be null)
  10505. * @returns a new raw 3D texture (stored in an InternalTexture)
  10506. */
  10507. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10508. /**
  10509. * Update a raw 3D texture
  10510. * @param texture defines the texture to update
  10511. * @param data defines the data to store
  10512. * @param format defines the data format
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. */
  10515. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10516. /**
  10517. * Update a raw 3D texture
  10518. * @param texture defines the texture to update
  10519. * @param data defines the data to store
  10520. * @param format defines the data format
  10521. * @param invertY defines if data must be stored with Y axis inverted
  10522. * @param compression defines the used compression (can be null)
  10523. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10524. */
  10525. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10526. /**
  10527. * Creates a new raw 2D array texture
  10528. * @param data defines the data used to create the texture
  10529. * @param width defines the width of the texture
  10530. * @param height defines the height of the texture
  10531. * @param depth defines the number of layers of the texture
  10532. * @param format defines the format of the texture
  10533. * @param generateMipMaps defines if the engine must generate mip levels
  10534. * @param invertY defines if data must be stored with Y axis inverted
  10535. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10536. * @param compression defines the compressed used (can be null)
  10537. * @param textureType defines the compressed used (can be null)
  10538. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10539. */
  10540. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10541. /**
  10542. * Update a raw 2D array texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store
  10545. * @param format defines the data format
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. */
  10548. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10549. /**
  10550. * Update a raw 2D array texture
  10551. * @param texture defines the texture to update
  10552. * @param data defines the data to store
  10553. * @param format defines the data format
  10554. * @param invertY defines if data must be stored with Y axis inverted
  10555. * @param compression defines the used compression (can be null)
  10556. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10557. */
  10558. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10559. }
  10560. }
  10561. declare module BABYLON {
  10562. /**
  10563. * Raw texture can help creating a texture directly from an array of data.
  10564. * This can be super useful if you either get the data from an uncompressed source or
  10565. * if you wish to create your texture pixel by pixel.
  10566. */
  10567. export class RawTexture extends Texture {
  10568. /**
  10569. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10570. */
  10571. format: number;
  10572. private _engine;
  10573. /**
  10574. * Instantiates a new RawTexture.
  10575. * Raw texture can help creating a texture directly from an array of data.
  10576. * This can be super useful if you either get the data from an uncompressed source or
  10577. * if you wish to create your texture pixel by pixel.
  10578. * @param data define the array of data to use to create the texture
  10579. * @param width define the width of the texture
  10580. * @param height define the height of the texture
  10581. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10582. * @param scene define the scene the texture belongs to
  10583. * @param generateMipMaps define whether mip maps should be generated or not
  10584. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10585. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10586. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10587. */
  10588. constructor(data: ArrayBufferView, width: number, height: number,
  10589. /**
  10590. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10591. */
  10592. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10593. /**
  10594. * Updates the texture underlying data.
  10595. * @param data Define the new data of the texture
  10596. */
  10597. update(data: ArrayBufferView): void;
  10598. /**
  10599. * Creates a luminance texture from some data.
  10600. * @param data Define the texture data
  10601. * @param width Define the width of the texture
  10602. * @param height Define the height of the texture
  10603. * @param scene Define the scene the texture belongs to
  10604. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10605. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10606. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10607. * @returns the luminance texture
  10608. */
  10609. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10610. /**
  10611. * Creates a luminance alpha texture from some data.
  10612. * @param data Define the texture data
  10613. * @param width Define the width of the texture
  10614. * @param height Define the height of the texture
  10615. * @param scene Define the scene the texture belongs to
  10616. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10617. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10618. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10619. * @returns the luminance alpha texture
  10620. */
  10621. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10622. /**
  10623. * Creates an alpha texture from some data.
  10624. * @param data Define the texture data
  10625. * @param width Define the width of the texture
  10626. * @param height Define the height of the texture
  10627. * @param scene Define the scene the texture belongs to
  10628. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10629. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10630. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10631. * @returns the alpha texture
  10632. */
  10633. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10634. /**
  10635. * Creates a RGB texture from some data.
  10636. * @param data Define the texture data
  10637. * @param width Define the width of the texture
  10638. * @param height Define the height of the texture
  10639. * @param scene Define the scene the texture belongs to
  10640. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10641. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10642. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10643. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10644. * @returns the RGB alpha texture
  10645. */
  10646. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10647. /**
  10648. * Creates a RGBA texture from some data.
  10649. * @param data Define the texture data
  10650. * @param width Define the width of the texture
  10651. * @param height Define the height of the texture
  10652. * @param scene Define the scene the texture belongs to
  10653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10657. * @returns the RGBA texture
  10658. */
  10659. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10660. /**
  10661. * Creates a R texture from some data.
  10662. * @param data Define the texture data
  10663. * @param width Define the width of the texture
  10664. * @param height Define the height of the texture
  10665. * @param scene Define the scene the texture belongs to
  10666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10670. * @returns the R texture
  10671. */
  10672. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10673. }
  10674. }
  10675. declare module BABYLON {
  10676. interface AbstractScene {
  10677. /**
  10678. * The list of procedural textures added to the scene
  10679. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10680. */
  10681. proceduralTextures: Array<ProceduralTexture>;
  10682. }
  10683. /**
  10684. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10685. * in a given scene.
  10686. */
  10687. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10688. /**
  10689. * The component name helpfull to identify the component in the list of scene components.
  10690. */
  10691. readonly name: string;
  10692. /**
  10693. * The scene the component belongs to.
  10694. */
  10695. scene: Scene;
  10696. /**
  10697. * Creates a new instance of the component for the given scene
  10698. * @param scene Defines the scene to register the component in
  10699. */
  10700. constructor(scene: Scene);
  10701. /**
  10702. * Registers the component in a given scene
  10703. */
  10704. register(): void;
  10705. /**
  10706. * Rebuilds the elements related to this component in case of
  10707. * context lost for instance.
  10708. */
  10709. rebuild(): void;
  10710. /**
  10711. * Disposes the component and the associated ressources.
  10712. */
  10713. dispose(): void;
  10714. private _beforeClear;
  10715. }
  10716. }
  10717. declare module BABYLON {
  10718. interface ThinEngine {
  10719. /**
  10720. * Creates a new render target cube texture
  10721. * @param size defines the size of the texture
  10722. * @param options defines the options used to create the texture
  10723. * @returns a new render target cube texture stored in an InternalTexture
  10724. */
  10725. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10726. }
  10727. }
  10728. declare module BABYLON {
  10729. /** @hidden */
  10730. export var proceduralVertexShader: {
  10731. name: string;
  10732. shader: string;
  10733. };
  10734. }
  10735. declare module BABYLON {
  10736. /**
  10737. * 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.
  10738. * This is the base class of any Procedural texture and contains most of the shareable code.
  10739. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10740. */
  10741. export class ProceduralTexture extends Texture {
  10742. isCube: boolean;
  10743. /**
  10744. * Define if the texture is enabled or not (disabled texture will not render)
  10745. */
  10746. isEnabled: boolean;
  10747. /**
  10748. * Define if the texture must be cleared before rendering (default is true)
  10749. */
  10750. autoClear: boolean;
  10751. /**
  10752. * Callback called when the texture is generated
  10753. */
  10754. onGenerated: () => void;
  10755. /**
  10756. * Event raised when the texture is generated
  10757. */
  10758. onGeneratedObservable: Observable<ProceduralTexture>;
  10759. /** @hidden */
  10760. _generateMipMaps: boolean;
  10761. /** @hidden **/
  10762. _effect: Effect;
  10763. /** @hidden */
  10764. _textures: {
  10765. [key: string]: Texture;
  10766. };
  10767. private _size;
  10768. private _currentRefreshId;
  10769. private _frameId;
  10770. private _refreshRate;
  10771. private _vertexBuffers;
  10772. private _indexBuffer;
  10773. private _uniforms;
  10774. private _samplers;
  10775. private _fragment;
  10776. private _floats;
  10777. private _ints;
  10778. private _floatsArrays;
  10779. private _colors3;
  10780. private _colors4;
  10781. private _vectors2;
  10782. private _vectors3;
  10783. private _matrices;
  10784. private _fallbackTexture;
  10785. private _fallbackTextureUsed;
  10786. private _engine;
  10787. private _cachedDefines;
  10788. private _contentUpdateId;
  10789. private _contentData;
  10790. /**
  10791. * Instantiates a new procedural texture.
  10792. * 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.
  10793. * This is the base class of any Procedural texture and contains most of the shareable code.
  10794. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10795. * @param name Define the name of the texture
  10796. * @param size Define the size of the texture to create
  10797. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10798. * @param scene Define the scene the texture belongs to
  10799. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10800. * @param generateMipMaps Define if the texture should creates mip maps or not
  10801. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10802. */
  10803. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10804. /**
  10805. * The effect that is created when initializing the post process.
  10806. * @returns The created effect corresponding the the postprocess.
  10807. */
  10808. getEffect(): Effect;
  10809. /**
  10810. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10811. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10812. */
  10813. getContent(): Nullable<ArrayBufferView>;
  10814. private _createIndexBuffer;
  10815. /** @hidden */
  10816. _rebuild(): void;
  10817. /**
  10818. * Resets the texture in order to recreate its associated resources.
  10819. * This can be called in case of context loss
  10820. */
  10821. reset(): void;
  10822. protected _getDefines(): string;
  10823. /**
  10824. * Is the texture ready to be used ? (rendered at least once)
  10825. * @returns true if ready, otherwise, false.
  10826. */
  10827. isReady(): boolean;
  10828. /**
  10829. * Resets the refresh counter of the texture and start bak from scratch.
  10830. * Could be useful to regenerate the texture if it is setup to render only once.
  10831. */
  10832. resetRefreshCounter(): void;
  10833. /**
  10834. * Set the fragment shader to use in order to render the texture.
  10835. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10836. */
  10837. setFragment(fragment: any): void;
  10838. /**
  10839. * Define the refresh rate of the texture or the rendering frequency.
  10840. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10841. */
  10842. get refreshRate(): number;
  10843. set refreshRate(value: number);
  10844. /** @hidden */
  10845. _shouldRender(): boolean;
  10846. /**
  10847. * Get the size the texture is rendering at.
  10848. * @returns the size (texture is always squared)
  10849. */
  10850. getRenderSize(): number;
  10851. /**
  10852. * Resize the texture to new value.
  10853. * @param size Define the new size the texture should have
  10854. * @param generateMipMaps Define whether the new texture should create mip maps
  10855. */
  10856. resize(size: number, generateMipMaps: boolean): void;
  10857. private _checkUniform;
  10858. /**
  10859. * Set a texture in the shader program used to render.
  10860. * @param name Define the name of the uniform samplers as defined in the shader
  10861. * @param texture Define the texture to bind to this sampler
  10862. * @return the texture itself allowing "fluent" like uniform updates
  10863. */
  10864. setTexture(name: string, texture: Texture): ProceduralTexture;
  10865. /**
  10866. * Set a float in the shader.
  10867. * @param name Define the name of the uniform as defined in the shader
  10868. * @param value Define the value to give to the uniform
  10869. * @return the texture itself allowing "fluent" like uniform updates
  10870. */
  10871. setFloat(name: string, value: number): ProceduralTexture;
  10872. /**
  10873. * Set a int in the shader.
  10874. * @param name Define the name of the uniform as defined in the shader
  10875. * @param value Define the value to give to the uniform
  10876. * @return the texture itself allowing "fluent" like uniform updates
  10877. */
  10878. setInt(name: string, value: number): ProceduralTexture;
  10879. /**
  10880. * Set an array of floats in the shader.
  10881. * @param name Define the name of the uniform as defined in the shader
  10882. * @param value Define the value to give to the uniform
  10883. * @return the texture itself allowing "fluent" like uniform updates
  10884. */
  10885. setFloats(name: string, value: number[]): ProceduralTexture;
  10886. /**
  10887. * Set a vec3 in the shader from a Color3.
  10888. * @param name Define the name of the uniform as defined in the shader
  10889. * @param value Define the value to give to the uniform
  10890. * @return the texture itself allowing "fluent" like uniform updates
  10891. */
  10892. setColor3(name: string, value: Color3): ProceduralTexture;
  10893. /**
  10894. * Set a vec4 in the shader from a Color4.
  10895. * @param name Define the name of the uniform as defined in the shader
  10896. * @param value Define the value to give to the uniform
  10897. * @return the texture itself allowing "fluent" like uniform updates
  10898. */
  10899. setColor4(name: string, value: Color4): ProceduralTexture;
  10900. /**
  10901. * Set a vec2 in the shader from a Vector2.
  10902. * @param name Define the name of the uniform as defined in the shader
  10903. * @param value Define the value to give to the uniform
  10904. * @return the texture itself allowing "fluent" like uniform updates
  10905. */
  10906. setVector2(name: string, value: Vector2): ProceduralTexture;
  10907. /**
  10908. * Set a vec3 in the shader from a Vector3.
  10909. * @param name Define the name of the uniform as defined in the shader
  10910. * @param value Define the value to give to the uniform
  10911. * @return the texture itself allowing "fluent" like uniform updates
  10912. */
  10913. setVector3(name: string, value: Vector3): ProceduralTexture;
  10914. /**
  10915. * Set a mat4 in the shader from a MAtrix.
  10916. * @param name Define the name of the uniform as defined in the shader
  10917. * @param value Define the value to give to the uniform
  10918. * @return the texture itself allowing "fluent" like uniform updates
  10919. */
  10920. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10921. /**
  10922. * Render the texture to its associated render target.
  10923. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10924. */
  10925. render(useCameraPostProcess?: boolean): void;
  10926. /**
  10927. * Clone the texture.
  10928. * @returns the cloned texture
  10929. */
  10930. clone(): ProceduralTexture;
  10931. /**
  10932. * Dispose the texture and release its asoociated resources.
  10933. */
  10934. dispose(): void;
  10935. }
  10936. }
  10937. declare module BABYLON {
  10938. /**
  10939. * This represents the base class for particle system in Babylon.
  10940. * 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.
  10941. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10942. * @example https://doc.babylonjs.com/babylon101/particles
  10943. */
  10944. export class BaseParticleSystem {
  10945. /**
  10946. * Source color is added to the destination color without alpha affecting the result
  10947. */
  10948. static BLENDMODE_ONEONE: number;
  10949. /**
  10950. * Blend current color and particle color using particle’s alpha
  10951. */
  10952. static BLENDMODE_STANDARD: number;
  10953. /**
  10954. * Add current color and particle color multiplied by particle’s alpha
  10955. */
  10956. static BLENDMODE_ADD: number;
  10957. /**
  10958. * Multiply current color with particle color
  10959. */
  10960. static BLENDMODE_MULTIPLY: number;
  10961. /**
  10962. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10963. */
  10964. static BLENDMODE_MULTIPLYADD: number;
  10965. /**
  10966. * List of animations used by the particle system.
  10967. */
  10968. animations: Animation[];
  10969. /**
  10970. * The id of the Particle system.
  10971. */
  10972. id: string;
  10973. /**
  10974. * The friendly name of the Particle system.
  10975. */
  10976. name: string;
  10977. /**
  10978. * The rendering group used by the Particle system to chose when to render.
  10979. */
  10980. renderingGroupId: number;
  10981. /**
  10982. * The emitter represents the Mesh or position we are attaching the particle system to.
  10983. */
  10984. emitter: Nullable<AbstractMesh | Vector3>;
  10985. /**
  10986. * The maximum number of particles to emit per frame
  10987. */
  10988. emitRate: number;
  10989. /**
  10990. * If you want to launch only a few particles at once, that can be done, as well.
  10991. */
  10992. manualEmitCount: number;
  10993. /**
  10994. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10995. */
  10996. updateSpeed: number;
  10997. /**
  10998. * The amount of time the particle system is running (depends of the overall update speed).
  10999. */
  11000. targetStopDuration: number;
  11001. /**
  11002. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11003. */
  11004. disposeOnStop: boolean;
  11005. /**
  11006. * Minimum power of emitting particles.
  11007. */
  11008. minEmitPower: number;
  11009. /**
  11010. * Maximum power of emitting particles.
  11011. */
  11012. maxEmitPower: number;
  11013. /**
  11014. * Minimum life time of emitting particles.
  11015. */
  11016. minLifeTime: number;
  11017. /**
  11018. * Maximum life time of emitting particles.
  11019. */
  11020. maxLifeTime: number;
  11021. /**
  11022. * Minimum Size of emitting particles.
  11023. */
  11024. minSize: number;
  11025. /**
  11026. * Maximum Size of emitting particles.
  11027. */
  11028. maxSize: number;
  11029. /**
  11030. * Minimum scale of emitting particles on X axis.
  11031. */
  11032. minScaleX: number;
  11033. /**
  11034. * Maximum scale of emitting particles on X axis.
  11035. */
  11036. maxScaleX: number;
  11037. /**
  11038. * Minimum scale of emitting particles on Y axis.
  11039. */
  11040. minScaleY: number;
  11041. /**
  11042. * Maximum scale of emitting particles on Y axis.
  11043. */
  11044. maxScaleY: number;
  11045. /**
  11046. * Gets or sets the minimal initial rotation in radians.
  11047. */
  11048. minInitialRotation: number;
  11049. /**
  11050. * Gets or sets the maximal initial rotation in radians.
  11051. */
  11052. maxInitialRotation: number;
  11053. /**
  11054. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11055. */
  11056. minAngularSpeed: number;
  11057. /**
  11058. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11059. */
  11060. maxAngularSpeed: number;
  11061. /**
  11062. * The texture used to render each particle. (this can be a spritesheet)
  11063. */
  11064. particleTexture: Nullable<Texture>;
  11065. /**
  11066. * The layer mask we are rendering the particles through.
  11067. */
  11068. layerMask: number;
  11069. /**
  11070. * This can help using your own shader to render the particle system.
  11071. * The according effect will be created
  11072. */
  11073. customShader: any;
  11074. /**
  11075. * By default particle system starts as soon as they are created. This prevents the
  11076. * automatic start to happen and let you decide when to start emitting particles.
  11077. */
  11078. preventAutoStart: boolean;
  11079. private _noiseTexture;
  11080. /**
  11081. * Gets or sets a texture used to add random noise to particle positions
  11082. */
  11083. get noiseTexture(): Nullable<ProceduralTexture>;
  11084. set noiseTexture(value: Nullable<ProceduralTexture>);
  11085. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11086. noiseStrength: Vector3;
  11087. /**
  11088. * Callback triggered when the particle animation is ending.
  11089. */
  11090. onAnimationEnd: Nullable<() => void>;
  11091. /**
  11092. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11093. */
  11094. blendMode: number;
  11095. /**
  11096. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11097. * to override the particles.
  11098. */
  11099. forceDepthWrite: boolean;
  11100. /** 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 */
  11101. preWarmCycles: number;
  11102. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11103. preWarmStepOffset: number;
  11104. /**
  11105. * 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)
  11106. */
  11107. spriteCellChangeSpeed: number;
  11108. /**
  11109. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11110. */
  11111. startSpriteCellID: number;
  11112. /**
  11113. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11114. */
  11115. endSpriteCellID: number;
  11116. /**
  11117. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11118. */
  11119. spriteCellWidth: number;
  11120. /**
  11121. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11122. */
  11123. spriteCellHeight: number;
  11124. /**
  11125. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11126. */
  11127. spriteRandomStartCell: boolean;
  11128. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11129. translationPivot: Vector2;
  11130. /** @hidden */
  11131. protected _isAnimationSheetEnabled: boolean;
  11132. /**
  11133. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11134. */
  11135. beginAnimationOnStart: boolean;
  11136. /**
  11137. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11138. */
  11139. beginAnimationFrom: number;
  11140. /**
  11141. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11142. */
  11143. beginAnimationTo: number;
  11144. /**
  11145. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11146. */
  11147. beginAnimationLoop: boolean;
  11148. /**
  11149. * Gets or sets a world offset applied to all particles
  11150. */
  11151. worldOffset: Vector3;
  11152. /**
  11153. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11154. */
  11155. get isAnimationSheetEnabled(): boolean;
  11156. set isAnimationSheetEnabled(value: boolean);
  11157. /**
  11158. * Get hosting scene
  11159. * @returns the scene
  11160. */
  11161. getScene(): Scene;
  11162. /**
  11163. * You can use gravity if you want to give an orientation to your particles.
  11164. */
  11165. gravity: Vector3;
  11166. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11167. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11168. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11169. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11170. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11171. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11172. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11173. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11174. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11175. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11176. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11177. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11178. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11179. /**
  11180. * Defines the delay in milliseconds before starting the system (0 by default)
  11181. */
  11182. startDelay: number;
  11183. /**
  11184. * Gets the current list of drag gradients.
  11185. * You must use addDragGradient and removeDragGradient to udpate this list
  11186. * @returns the list of drag gradients
  11187. */
  11188. getDragGradients(): Nullable<Array<FactorGradient>>;
  11189. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11190. limitVelocityDamping: number;
  11191. /**
  11192. * Gets the current list of limit velocity gradients.
  11193. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11194. * @returns the list of limit velocity gradients
  11195. */
  11196. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11197. /**
  11198. * Gets the current list of color gradients.
  11199. * You must use addColorGradient and removeColorGradient to udpate this list
  11200. * @returns the list of color gradients
  11201. */
  11202. getColorGradients(): Nullable<Array<ColorGradient>>;
  11203. /**
  11204. * Gets the current list of size gradients.
  11205. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11206. * @returns the list of size gradients
  11207. */
  11208. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11209. /**
  11210. * Gets the current list of color remap gradients.
  11211. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11212. * @returns the list of color remap gradients
  11213. */
  11214. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11215. /**
  11216. * Gets the current list of alpha remap gradients.
  11217. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11218. * @returns the list of alpha remap gradients
  11219. */
  11220. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11221. /**
  11222. * Gets the current list of life time gradients.
  11223. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11224. * @returns the list of life time gradients
  11225. */
  11226. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11227. /**
  11228. * Gets the current list of angular speed gradients.
  11229. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11230. * @returns the list of angular speed gradients
  11231. */
  11232. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11233. /**
  11234. * Gets the current list of velocity gradients.
  11235. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11236. * @returns the list of velocity gradients
  11237. */
  11238. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11239. /**
  11240. * Gets the current list of start size gradients.
  11241. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11242. * @returns the list of start size gradients
  11243. */
  11244. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11245. /**
  11246. * Gets the current list of emit rate gradients.
  11247. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11248. * @returns the list of emit rate gradients
  11249. */
  11250. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11251. /**
  11252. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11253. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11254. */
  11255. get direction1(): Vector3;
  11256. set direction1(value: Vector3);
  11257. /**
  11258. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11259. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11260. */
  11261. get direction2(): Vector3;
  11262. set direction2(value: Vector3);
  11263. /**
  11264. * 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.
  11265. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11266. */
  11267. get minEmitBox(): Vector3;
  11268. set minEmitBox(value: Vector3);
  11269. /**
  11270. * 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.
  11271. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11272. */
  11273. get maxEmitBox(): Vector3;
  11274. set maxEmitBox(value: Vector3);
  11275. /**
  11276. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11277. */
  11278. color1: Color4;
  11279. /**
  11280. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11281. */
  11282. color2: Color4;
  11283. /**
  11284. * Color the particle will have at the end of its lifetime
  11285. */
  11286. colorDead: Color4;
  11287. /**
  11288. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11289. */
  11290. textureMask: Color4;
  11291. /**
  11292. * The particle emitter type defines the emitter used by the particle system.
  11293. * It can be for example box, sphere, or cone...
  11294. */
  11295. particleEmitterType: IParticleEmitterType;
  11296. /** @hidden */
  11297. _isSubEmitter: boolean;
  11298. /**
  11299. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11300. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11301. */
  11302. billboardMode: number;
  11303. protected _isBillboardBased: boolean;
  11304. /**
  11305. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11306. */
  11307. get isBillboardBased(): boolean;
  11308. set isBillboardBased(value: boolean);
  11309. /**
  11310. * The scene the particle system belongs to.
  11311. */
  11312. protected _scene: Scene;
  11313. /**
  11314. * Local cache of defines for image processing.
  11315. */
  11316. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11317. /**
  11318. * Default configuration related to image processing available in the standard Material.
  11319. */
  11320. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11321. /**
  11322. * Gets the image processing configuration used either in this material.
  11323. */
  11324. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11325. /**
  11326. * Sets the Default image processing configuration used either in the this material.
  11327. *
  11328. * If sets to null, the scene one is in use.
  11329. */
  11330. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11331. /**
  11332. * Attaches a new image processing configuration to the Standard Material.
  11333. * @param configuration
  11334. */
  11335. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11336. /** @hidden */
  11337. protected _reset(): void;
  11338. /** @hidden */
  11339. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11340. /**
  11341. * Instantiates a particle system.
  11342. * 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.
  11343. * @param name The name of the particle system
  11344. */
  11345. constructor(name: string);
  11346. /**
  11347. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11350. * @returns the emitter
  11351. */
  11352. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11353. /**
  11354. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11355. * @param radius The radius of the hemisphere to emit from
  11356. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11357. * @returns the emitter
  11358. */
  11359. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11360. /**
  11361. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11362. * @param radius The radius of the sphere to emit from
  11363. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11364. * @returns the emitter
  11365. */
  11366. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11367. /**
  11368. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11369. * @param radius The radius of the sphere to emit from
  11370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11372. * @returns the emitter
  11373. */
  11374. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11375. /**
  11376. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11377. * @param radius The radius of the emission cylinder
  11378. * @param height The height of the emission cylinder
  11379. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11380. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11381. * @returns the emitter
  11382. */
  11383. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11384. /**
  11385. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11386. * @param radius The radius of the cylinder to emit from
  11387. * @param height The height of the emission cylinder
  11388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11391. * @returns the emitter
  11392. */
  11393. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11394. /**
  11395. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11396. * @param radius The radius of the cone to emit from
  11397. * @param angle The base angle of the cone
  11398. * @returns the emitter
  11399. */
  11400. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11401. /**
  11402. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11405. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11406. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11407. * @returns the emitter
  11408. */
  11409. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11410. }
  11411. }
  11412. declare module BABYLON {
  11413. /**
  11414. * Type of sub emitter
  11415. */
  11416. export enum SubEmitterType {
  11417. /**
  11418. * Attached to the particle over it's lifetime
  11419. */
  11420. ATTACHED = 0,
  11421. /**
  11422. * Created when the particle dies
  11423. */
  11424. END = 1
  11425. }
  11426. /**
  11427. * Sub emitter class used to emit particles from an existing particle
  11428. */
  11429. export class SubEmitter {
  11430. /**
  11431. * the particle system to be used by the sub emitter
  11432. */
  11433. particleSystem: ParticleSystem;
  11434. /**
  11435. * Type of the submitter (Default: END)
  11436. */
  11437. type: SubEmitterType;
  11438. /**
  11439. * 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)
  11440. * Note: This only is supported when using an emitter of type Mesh
  11441. */
  11442. inheritDirection: boolean;
  11443. /**
  11444. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11445. */
  11446. inheritedVelocityAmount: number;
  11447. /**
  11448. * Creates a sub emitter
  11449. * @param particleSystem the particle system to be used by the sub emitter
  11450. */
  11451. constructor(
  11452. /**
  11453. * the particle system to be used by the sub emitter
  11454. */
  11455. particleSystem: ParticleSystem);
  11456. /**
  11457. * Clones the sub emitter
  11458. * @returns the cloned sub emitter
  11459. */
  11460. clone(): SubEmitter;
  11461. /**
  11462. * Serialize current object to a JSON object
  11463. * @returns the serialized object
  11464. */
  11465. serialize(): any;
  11466. /** @hidden */
  11467. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11468. /**
  11469. * Creates a new SubEmitter from a serialized JSON version
  11470. * @param serializationObject defines the JSON object to read from
  11471. * @param scene defines the hosting scene
  11472. * @param rootUrl defines the rootUrl for data loading
  11473. * @returns a new SubEmitter
  11474. */
  11475. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11476. /** Release associated resources */
  11477. dispose(): void;
  11478. }
  11479. }
  11480. declare module BABYLON {
  11481. /** @hidden */
  11482. export var imageProcessingDeclaration: {
  11483. name: string;
  11484. shader: string;
  11485. };
  11486. }
  11487. declare module BABYLON {
  11488. /** @hidden */
  11489. export var imageProcessingFunctions: {
  11490. name: string;
  11491. shader: string;
  11492. };
  11493. }
  11494. declare module BABYLON {
  11495. /** @hidden */
  11496. export var particlesPixelShader: {
  11497. name: string;
  11498. shader: string;
  11499. };
  11500. }
  11501. declare module BABYLON {
  11502. /** @hidden */
  11503. export var particlesVertexShader: {
  11504. name: string;
  11505. shader: string;
  11506. };
  11507. }
  11508. declare module BABYLON {
  11509. /**
  11510. * This represents a particle system in Babylon.
  11511. * 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.
  11512. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11513. * @example https://doc.babylonjs.com/babylon101/particles
  11514. */
  11515. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11516. /**
  11517. * Billboard mode will only apply to Y axis
  11518. */
  11519. static readonly BILLBOARDMODE_Y: number;
  11520. /**
  11521. * Billboard mode will apply to all axes
  11522. */
  11523. static readonly BILLBOARDMODE_ALL: number;
  11524. /**
  11525. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11526. */
  11527. static readonly BILLBOARDMODE_STRETCHED: number;
  11528. /**
  11529. * This function can be defined to provide custom update for active particles.
  11530. * This function will be called instead of regular update (age, position, color, etc.).
  11531. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11532. */
  11533. updateFunction: (particles: Particle[]) => void;
  11534. private _emitterWorldMatrix;
  11535. /**
  11536. * This function can be defined to specify initial direction for every new particle.
  11537. * It by default use the emitterType defined function
  11538. */
  11539. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11540. /**
  11541. * This function can be defined to specify initial position for every new particle.
  11542. * It by default use the emitterType defined function
  11543. */
  11544. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11545. /**
  11546. * @hidden
  11547. */
  11548. _inheritedVelocityOffset: Vector3;
  11549. /**
  11550. * An event triggered when the system is disposed
  11551. */
  11552. onDisposeObservable: Observable<ParticleSystem>;
  11553. private _onDisposeObserver;
  11554. /**
  11555. * Sets a callback that will be triggered when the system is disposed
  11556. */
  11557. set onDispose(callback: () => void);
  11558. private _particles;
  11559. private _epsilon;
  11560. private _capacity;
  11561. private _stockParticles;
  11562. private _newPartsExcess;
  11563. private _vertexData;
  11564. private _vertexBuffer;
  11565. private _vertexBuffers;
  11566. private _spriteBuffer;
  11567. private _indexBuffer;
  11568. private _effect;
  11569. private _customEffect;
  11570. private _cachedDefines;
  11571. private _scaledColorStep;
  11572. private _colorDiff;
  11573. private _scaledDirection;
  11574. private _scaledGravity;
  11575. private _currentRenderId;
  11576. private _alive;
  11577. private _useInstancing;
  11578. private _started;
  11579. private _stopped;
  11580. private _actualFrame;
  11581. private _scaledUpdateSpeed;
  11582. private _vertexBufferSize;
  11583. /** @hidden */
  11584. _currentEmitRateGradient: Nullable<FactorGradient>;
  11585. /** @hidden */
  11586. _currentEmitRate1: number;
  11587. /** @hidden */
  11588. _currentEmitRate2: number;
  11589. /** @hidden */
  11590. _currentStartSizeGradient: Nullable<FactorGradient>;
  11591. /** @hidden */
  11592. _currentStartSize1: number;
  11593. /** @hidden */
  11594. _currentStartSize2: number;
  11595. private readonly _rawTextureWidth;
  11596. private _rampGradientsTexture;
  11597. private _useRampGradients;
  11598. /** Gets or sets a boolean indicating that ramp gradients must be used
  11599. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11600. */
  11601. get useRampGradients(): boolean;
  11602. set useRampGradients(value: boolean);
  11603. /**
  11604. * 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.
  11605. * 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: [])
  11606. */
  11607. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11608. private _subEmitters;
  11609. /**
  11610. * @hidden
  11611. * If the particle systems emitter should be disposed when the particle system is disposed
  11612. */
  11613. _disposeEmitterOnDispose: boolean;
  11614. /**
  11615. * The current active Sub-systems, this property is used by the root particle system only.
  11616. */
  11617. activeSubSystems: Array<ParticleSystem>;
  11618. private _rootParticleSystem;
  11619. /**
  11620. * Gets the current list of active particles
  11621. */
  11622. get particles(): Particle[];
  11623. /**
  11624. * Returns the string "ParticleSystem"
  11625. * @returns a string containing the class name
  11626. */
  11627. getClassName(): string;
  11628. /**
  11629. * Instantiates a particle system.
  11630. * 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.
  11631. * @param name The name of the particle system
  11632. * @param capacity The max number of particles alive at the same time
  11633. * @param scene The scene the particle system belongs to
  11634. * @param customEffect a custom effect used to change the way particles are rendered by default
  11635. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11636. * @param epsilon Offset used to render the particles
  11637. */
  11638. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11639. private _addFactorGradient;
  11640. private _removeFactorGradient;
  11641. /**
  11642. * Adds a new life time gradient
  11643. * @param gradient defines the gradient to use (between 0 and 1)
  11644. * @param factor defines the life time factor to affect to the specified gradient
  11645. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11646. * @returns the current particle system
  11647. */
  11648. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11649. /**
  11650. * Remove a specific life time gradient
  11651. * @param gradient defines the gradient to remove
  11652. * @returns the current particle system
  11653. */
  11654. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11655. /**
  11656. * Adds a new size gradient
  11657. * @param gradient defines the gradient to use (between 0 and 1)
  11658. * @param factor defines the size factor to affect to the specified gradient
  11659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11660. * @returns the current particle system
  11661. */
  11662. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11663. /**
  11664. * Remove a specific size gradient
  11665. * @param gradient defines the gradient to remove
  11666. * @returns the current particle system
  11667. */
  11668. removeSizeGradient(gradient: number): IParticleSystem;
  11669. /**
  11670. * Adds a new color remap gradient
  11671. * @param gradient defines the gradient to use (between 0 and 1)
  11672. * @param min defines the color remap minimal range
  11673. * @param max defines the color remap maximal range
  11674. * @returns the current particle system
  11675. */
  11676. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11677. /**
  11678. * Remove a specific color remap gradient
  11679. * @param gradient defines the gradient to remove
  11680. * @returns the current particle system
  11681. */
  11682. removeColorRemapGradient(gradient: number): IParticleSystem;
  11683. /**
  11684. * Adds a new alpha remap gradient
  11685. * @param gradient defines the gradient to use (between 0 and 1)
  11686. * @param min defines the alpha remap minimal range
  11687. * @param max defines the alpha remap maximal range
  11688. * @returns the current particle system
  11689. */
  11690. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11691. /**
  11692. * Remove a specific alpha remap gradient
  11693. * @param gradient defines the gradient to remove
  11694. * @returns the current particle system
  11695. */
  11696. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11697. /**
  11698. * Adds a new angular speed gradient
  11699. * @param gradient defines the gradient to use (between 0 and 1)
  11700. * @param factor defines the angular speed to affect to the specified gradient
  11701. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11702. * @returns the current particle system
  11703. */
  11704. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11705. /**
  11706. * Remove a specific angular speed gradient
  11707. * @param gradient defines the gradient to remove
  11708. * @returns the current particle system
  11709. */
  11710. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11711. /**
  11712. * Adds a new velocity gradient
  11713. * @param gradient defines the gradient to use (between 0 and 1)
  11714. * @param factor defines the velocity to affect to the specified gradient
  11715. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11716. * @returns the current particle system
  11717. */
  11718. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11719. /**
  11720. * Remove a specific velocity gradient
  11721. * @param gradient defines the gradient to remove
  11722. * @returns the current particle system
  11723. */
  11724. removeVelocityGradient(gradient: number): IParticleSystem;
  11725. /**
  11726. * Adds a new limit velocity gradient
  11727. * @param gradient defines the gradient to use (between 0 and 1)
  11728. * @param factor defines the limit velocity value to affect to the specified gradient
  11729. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11730. * @returns the current particle system
  11731. */
  11732. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11733. /**
  11734. * Remove a specific limit velocity gradient
  11735. * @param gradient defines the gradient to remove
  11736. * @returns the current particle system
  11737. */
  11738. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11739. /**
  11740. * Adds a new drag gradient
  11741. * @param gradient defines the gradient to use (between 0 and 1)
  11742. * @param factor defines the drag value to affect to the specified gradient
  11743. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11744. * @returns the current particle system
  11745. */
  11746. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11747. /**
  11748. * Remove a specific drag gradient
  11749. * @param gradient defines the gradient to remove
  11750. * @returns the current particle system
  11751. */
  11752. removeDragGradient(gradient: number): IParticleSystem;
  11753. /**
  11754. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11755. * @param gradient defines the gradient to use (between 0 and 1)
  11756. * @param factor defines the emit rate value to affect to the specified gradient
  11757. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11758. * @returns the current particle system
  11759. */
  11760. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11761. /**
  11762. * Remove a specific emit rate gradient
  11763. * @param gradient defines the gradient to remove
  11764. * @returns the current particle system
  11765. */
  11766. removeEmitRateGradient(gradient: number): IParticleSystem;
  11767. /**
  11768. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11769. * @param gradient defines the gradient to use (between 0 and 1)
  11770. * @param factor defines the start size value to affect to the specified gradient
  11771. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11772. * @returns the current particle system
  11773. */
  11774. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11775. /**
  11776. * Remove a specific start size gradient
  11777. * @param gradient defines the gradient to remove
  11778. * @returns the current particle system
  11779. */
  11780. removeStartSizeGradient(gradient: number): IParticleSystem;
  11781. private _createRampGradientTexture;
  11782. /**
  11783. * Gets the current list of ramp gradients.
  11784. * You must use addRampGradient and removeRampGradient to udpate this list
  11785. * @returns the list of ramp gradients
  11786. */
  11787. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11788. /**
  11789. * Adds a new ramp gradient used to remap particle colors
  11790. * @param gradient defines the gradient to use (between 0 and 1)
  11791. * @param color defines the color to affect to the specified gradient
  11792. * @returns the current particle system
  11793. */
  11794. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11795. /**
  11796. * Remove a specific ramp gradient
  11797. * @param gradient defines the gradient to remove
  11798. * @returns the current particle system
  11799. */
  11800. removeRampGradient(gradient: number): ParticleSystem;
  11801. /**
  11802. * Adds a new color gradient
  11803. * @param gradient defines the gradient to use (between 0 and 1)
  11804. * @param color1 defines the color to affect to the specified gradient
  11805. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11806. * @returns this particle system
  11807. */
  11808. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11809. /**
  11810. * Remove a specific color gradient
  11811. * @param gradient defines the gradient to remove
  11812. * @returns this particle system
  11813. */
  11814. removeColorGradient(gradient: number): IParticleSystem;
  11815. private _fetchR;
  11816. protected _reset(): void;
  11817. private _resetEffect;
  11818. private _createVertexBuffers;
  11819. private _createIndexBuffer;
  11820. /**
  11821. * Gets the maximum number of particles active at the same time.
  11822. * @returns The max number of active particles.
  11823. */
  11824. getCapacity(): number;
  11825. /**
  11826. * Gets whether there are still active particles in the system.
  11827. * @returns True if it is alive, otherwise false.
  11828. */
  11829. isAlive(): boolean;
  11830. /**
  11831. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11832. * @returns True if it has been started, otherwise false.
  11833. */
  11834. isStarted(): boolean;
  11835. private _prepareSubEmitterInternalArray;
  11836. /**
  11837. * Starts the particle system and begins to emit
  11838. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11839. */
  11840. start(delay?: number): void;
  11841. /**
  11842. * Stops the particle system.
  11843. * @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.
  11844. */
  11845. stop(stopSubEmitters?: boolean): void;
  11846. /**
  11847. * Remove all active particles
  11848. */
  11849. reset(): void;
  11850. /**
  11851. * @hidden (for internal use only)
  11852. */
  11853. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11854. /**
  11855. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11856. * Its lifetime will start back at 0.
  11857. */
  11858. recycleParticle: (particle: Particle) => void;
  11859. private _stopSubEmitters;
  11860. private _createParticle;
  11861. private _removeFromRoot;
  11862. private _emitFromParticle;
  11863. private _update;
  11864. /** @hidden */
  11865. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11866. /** @hidden */
  11867. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11868. /** @hidden */
  11869. private _getEffect;
  11870. /**
  11871. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11872. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11873. */
  11874. animate(preWarmOnly?: boolean): void;
  11875. private _appendParticleVertices;
  11876. /**
  11877. * Rebuilds the particle system.
  11878. */
  11879. rebuild(): void;
  11880. /**
  11881. * Is this system ready to be used/rendered
  11882. * @return true if the system is ready
  11883. */
  11884. isReady(): boolean;
  11885. private _render;
  11886. /**
  11887. * Renders the particle system in its current state.
  11888. * @returns the current number of particles
  11889. */
  11890. render(): number;
  11891. /**
  11892. * Disposes the particle system and free the associated resources
  11893. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11894. */
  11895. dispose(disposeTexture?: boolean): void;
  11896. /**
  11897. * Clones the particle system.
  11898. * @param name The name of the cloned object
  11899. * @param newEmitter The new emitter to use
  11900. * @returns the cloned particle system
  11901. */
  11902. clone(name: string, newEmitter: any): ParticleSystem;
  11903. /**
  11904. * Serializes the particle system to a JSON object.
  11905. * @returns the JSON object
  11906. */
  11907. serialize(): any;
  11908. /** @hidden */
  11909. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11910. /** @hidden */
  11911. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11912. /**
  11913. * Parses a JSON object to create a particle system.
  11914. * @param parsedParticleSystem The JSON object to parse
  11915. * @param scene The scene to create the particle system in
  11916. * @param rootUrl The root url to use to load external dependencies like texture
  11917. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11918. * @returns the Parsed particle system
  11919. */
  11920. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11921. }
  11922. }
  11923. declare module BABYLON {
  11924. /**
  11925. * A particle represents one of the element emitted by a particle system.
  11926. * This is mainly define by its coordinates, direction, velocity and age.
  11927. */
  11928. export class Particle {
  11929. /**
  11930. * The particle system the particle belongs to.
  11931. */
  11932. particleSystem: ParticleSystem;
  11933. private static _Count;
  11934. /**
  11935. * Unique ID of the particle
  11936. */
  11937. id: number;
  11938. /**
  11939. * The world position of the particle in the scene.
  11940. */
  11941. position: Vector3;
  11942. /**
  11943. * The world direction of the particle in the scene.
  11944. */
  11945. direction: Vector3;
  11946. /**
  11947. * The color of the particle.
  11948. */
  11949. color: Color4;
  11950. /**
  11951. * The color change of the particle per step.
  11952. */
  11953. colorStep: Color4;
  11954. /**
  11955. * Defines how long will the life of the particle be.
  11956. */
  11957. lifeTime: number;
  11958. /**
  11959. * The current age of the particle.
  11960. */
  11961. age: number;
  11962. /**
  11963. * The current size of the particle.
  11964. */
  11965. size: number;
  11966. /**
  11967. * The current scale of the particle.
  11968. */
  11969. scale: Vector2;
  11970. /**
  11971. * The current angle of the particle.
  11972. */
  11973. angle: number;
  11974. /**
  11975. * Defines how fast is the angle changing.
  11976. */
  11977. angularSpeed: number;
  11978. /**
  11979. * Defines the cell index used by the particle to be rendered from a sprite.
  11980. */
  11981. cellIndex: number;
  11982. /**
  11983. * The information required to support color remapping
  11984. */
  11985. remapData: Vector4;
  11986. /** @hidden */
  11987. _randomCellOffset?: number;
  11988. /** @hidden */
  11989. _initialDirection: Nullable<Vector3>;
  11990. /** @hidden */
  11991. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11992. /** @hidden */
  11993. _initialStartSpriteCellID: number;
  11994. /** @hidden */
  11995. _initialEndSpriteCellID: number;
  11996. /** @hidden */
  11997. _currentColorGradient: Nullable<ColorGradient>;
  11998. /** @hidden */
  11999. _currentColor1: Color4;
  12000. /** @hidden */
  12001. _currentColor2: Color4;
  12002. /** @hidden */
  12003. _currentSizeGradient: Nullable<FactorGradient>;
  12004. /** @hidden */
  12005. _currentSize1: number;
  12006. /** @hidden */
  12007. _currentSize2: number;
  12008. /** @hidden */
  12009. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12010. /** @hidden */
  12011. _currentAngularSpeed1: number;
  12012. /** @hidden */
  12013. _currentAngularSpeed2: number;
  12014. /** @hidden */
  12015. _currentVelocityGradient: Nullable<FactorGradient>;
  12016. /** @hidden */
  12017. _currentVelocity1: number;
  12018. /** @hidden */
  12019. _currentVelocity2: number;
  12020. /** @hidden */
  12021. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12022. /** @hidden */
  12023. _currentLimitVelocity1: number;
  12024. /** @hidden */
  12025. _currentLimitVelocity2: number;
  12026. /** @hidden */
  12027. _currentDragGradient: Nullable<FactorGradient>;
  12028. /** @hidden */
  12029. _currentDrag1: number;
  12030. /** @hidden */
  12031. _currentDrag2: number;
  12032. /** @hidden */
  12033. _randomNoiseCoordinates1: Vector3;
  12034. /** @hidden */
  12035. _randomNoiseCoordinates2: Vector3;
  12036. /**
  12037. * Creates a new instance Particle
  12038. * @param particleSystem the particle system the particle belongs to
  12039. */
  12040. constructor(
  12041. /**
  12042. * The particle system the particle belongs to.
  12043. */
  12044. particleSystem: ParticleSystem);
  12045. private updateCellInfoFromSystem;
  12046. /**
  12047. * Defines how the sprite cell index is updated for the particle
  12048. */
  12049. updateCellIndex(): void;
  12050. /** @hidden */
  12051. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12052. /** @hidden */
  12053. _inheritParticleInfoToSubEmitters(): void;
  12054. /** @hidden */
  12055. _reset(): void;
  12056. /**
  12057. * Copy the properties of particle to another one.
  12058. * @param other the particle to copy the information to.
  12059. */
  12060. copyTo(other: Particle): void;
  12061. }
  12062. }
  12063. declare module BABYLON {
  12064. /**
  12065. * Particle emitter represents a volume emitting particles.
  12066. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12067. */
  12068. export interface IParticleEmitterType {
  12069. /**
  12070. * Called by the particle System when the direction is computed for the created particle.
  12071. * @param worldMatrix is the world matrix of the particle system
  12072. * @param directionToUpdate is the direction vector to update with the result
  12073. * @param particle is the particle we are computed the direction for
  12074. */
  12075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12076. /**
  12077. * Called by the particle System when the position is computed for the created particle.
  12078. * @param worldMatrix is the world matrix of the particle system
  12079. * @param positionToUpdate is the position vector to update with the result
  12080. * @param particle is the particle we are computed the position for
  12081. */
  12082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12083. /**
  12084. * Clones the current emitter and returns a copy of it
  12085. * @returns the new emitter
  12086. */
  12087. clone(): IParticleEmitterType;
  12088. /**
  12089. * Called by the GPUParticleSystem to setup the update shader
  12090. * @param effect defines the update shader
  12091. */
  12092. applyToShader(effect: Effect): void;
  12093. /**
  12094. * Returns a string to use to update the GPU particles update shader
  12095. * @returns the effect defines string
  12096. */
  12097. getEffectDefines(): string;
  12098. /**
  12099. * Returns a string representing the class name
  12100. * @returns a string containing the class name
  12101. */
  12102. getClassName(): string;
  12103. /**
  12104. * Serializes the particle system to a JSON object.
  12105. * @returns the JSON object
  12106. */
  12107. serialize(): any;
  12108. /**
  12109. * Parse properties from a JSON object
  12110. * @param serializationObject defines the JSON object
  12111. * @param scene defines the hosting scene
  12112. */
  12113. parse(serializationObject: any, scene: Scene): void;
  12114. }
  12115. }
  12116. declare module BABYLON {
  12117. /**
  12118. * Particle emitter emitting particles from the inside of a box.
  12119. * It emits the particles randomly between 2 given directions.
  12120. */
  12121. export class BoxParticleEmitter implements IParticleEmitterType {
  12122. /**
  12123. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12124. */
  12125. direction1: Vector3;
  12126. /**
  12127. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12128. */
  12129. direction2: Vector3;
  12130. /**
  12131. * 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.
  12132. */
  12133. minEmitBox: Vector3;
  12134. /**
  12135. * 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.
  12136. */
  12137. maxEmitBox: Vector3;
  12138. /**
  12139. * Creates a new instance BoxParticleEmitter
  12140. */
  12141. constructor();
  12142. /**
  12143. * Called by the particle System when the direction is computed for the created particle.
  12144. * @param worldMatrix is the world matrix of the particle system
  12145. * @param directionToUpdate is the direction vector to update with the result
  12146. * @param particle is the particle we are computed the direction for
  12147. */
  12148. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12149. /**
  12150. * Called by the particle System when the position is computed for the created particle.
  12151. * @param worldMatrix is the world matrix of the particle system
  12152. * @param positionToUpdate is the position vector to update with the result
  12153. * @param particle is the particle we are computed the position for
  12154. */
  12155. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12156. /**
  12157. * Clones the current emitter and returns a copy of it
  12158. * @returns the new emitter
  12159. */
  12160. clone(): BoxParticleEmitter;
  12161. /**
  12162. * Called by the GPUParticleSystem to setup the update shader
  12163. * @param effect defines the update shader
  12164. */
  12165. applyToShader(effect: Effect): void;
  12166. /**
  12167. * Returns a string to use to update the GPU particles update shader
  12168. * @returns a string containng the defines string
  12169. */
  12170. getEffectDefines(): string;
  12171. /**
  12172. * Returns the string "BoxParticleEmitter"
  12173. * @returns a string containing the class name
  12174. */
  12175. getClassName(): string;
  12176. /**
  12177. * Serializes the particle system to a JSON object.
  12178. * @returns the JSON object
  12179. */
  12180. serialize(): any;
  12181. /**
  12182. * Parse properties from a JSON object
  12183. * @param serializationObject defines the JSON object
  12184. */
  12185. parse(serializationObject: any): void;
  12186. }
  12187. }
  12188. declare module BABYLON {
  12189. /**
  12190. * Particle emitter emitting particles from the inside of a cone.
  12191. * It emits the particles alongside the cone volume from the base to the particle.
  12192. * The emission direction might be randomized.
  12193. */
  12194. export class ConeParticleEmitter implements IParticleEmitterType {
  12195. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12196. directionRandomizer: number;
  12197. private _radius;
  12198. private _angle;
  12199. private _height;
  12200. /**
  12201. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12202. */
  12203. radiusRange: number;
  12204. /**
  12205. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12206. */
  12207. heightRange: number;
  12208. /**
  12209. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12210. */
  12211. emitFromSpawnPointOnly: boolean;
  12212. /**
  12213. * Gets or sets the radius of the emission cone
  12214. */
  12215. get radius(): number;
  12216. set radius(value: number);
  12217. /**
  12218. * Gets or sets the angle of the emission cone
  12219. */
  12220. get angle(): number;
  12221. set angle(value: number);
  12222. private _buildHeight;
  12223. /**
  12224. * Creates a new instance ConeParticleEmitter
  12225. * @param radius the radius of the emission cone (1 by default)
  12226. * @param angle the cone base angle (PI by default)
  12227. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12228. */
  12229. constructor(radius?: number, angle?: number,
  12230. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12231. directionRandomizer?: number);
  12232. /**
  12233. * Called by the particle System when the direction is computed for the created particle.
  12234. * @param worldMatrix is the world matrix of the particle system
  12235. * @param directionToUpdate is the direction vector to update with the result
  12236. * @param particle is the particle we are computed the direction for
  12237. */
  12238. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12239. /**
  12240. * Called by the particle System when the position is computed for the created particle.
  12241. * @param worldMatrix is the world matrix of the particle system
  12242. * @param positionToUpdate is the position vector to update with the result
  12243. * @param particle is the particle we are computed the position for
  12244. */
  12245. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12246. /**
  12247. * Clones the current emitter and returns a copy of it
  12248. * @returns the new emitter
  12249. */
  12250. clone(): ConeParticleEmitter;
  12251. /**
  12252. * Called by the GPUParticleSystem to setup the update shader
  12253. * @param effect defines the update shader
  12254. */
  12255. applyToShader(effect: Effect): void;
  12256. /**
  12257. * Returns a string to use to update the GPU particles update shader
  12258. * @returns a string containng the defines string
  12259. */
  12260. getEffectDefines(): string;
  12261. /**
  12262. * Returns the string "ConeParticleEmitter"
  12263. * @returns a string containing the class name
  12264. */
  12265. getClassName(): string;
  12266. /**
  12267. * Serializes the particle system to a JSON object.
  12268. * @returns the JSON object
  12269. */
  12270. serialize(): any;
  12271. /**
  12272. * Parse properties from a JSON object
  12273. * @param serializationObject defines the JSON object
  12274. */
  12275. parse(serializationObject: any): void;
  12276. }
  12277. }
  12278. declare module BABYLON {
  12279. /**
  12280. * Particle emitter emitting particles from the inside of a cylinder.
  12281. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12282. */
  12283. export class CylinderParticleEmitter implements IParticleEmitterType {
  12284. /**
  12285. * The radius of the emission cylinder.
  12286. */
  12287. radius: number;
  12288. /**
  12289. * The height of the emission cylinder.
  12290. */
  12291. height: number;
  12292. /**
  12293. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12294. */
  12295. radiusRange: number;
  12296. /**
  12297. * How much to randomize the particle direction [0-1].
  12298. */
  12299. directionRandomizer: number;
  12300. /**
  12301. * Creates a new instance CylinderParticleEmitter
  12302. * @param radius the radius of the emission cylinder (1 by default)
  12303. * @param height the height of the emission cylinder (1 by default)
  12304. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12305. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12306. */
  12307. constructor(
  12308. /**
  12309. * The radius of the emission cylinder.
  12310. */
  12311. radius?: number,
  12312. /**
  12313. * The height of the emission cylinder.
  12314. */
  12315. height?: number,
  12316. /**
  12317. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12318. */
  12319. radiusRange?: number,
  12320. /**
  12321. * How much to randomize the particle direction [0-1].
  12322. */
  12323. directionRandomizer?: number);
  12324. /**
  12325. * Called by the particle System when the direction is computed for the created particle.
  12326. * @param worldMatrix is the world matrix of the particle system
  12327. * @param directionToUpdate is the direction vector to update with the result
  12328. * @param particle is the particle we are computed the direction for
  12329. */
  12330. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12331. /**
  12332. * Called by the particle System when the position is computed for the created particle.
  12333. * @param worldMatrix is the world matrix of the particle system
  12334. * @param positionToUpdate is the position vector to update with the result
  12335. * @param particle is the particle we are computed the position for
  12336. */
  12337. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12338. /**
  12339. * Clones the current emitter and returns a copy of it
  12340. * @returns the new emitter
  12341. */
  12342. clone(): CylinderParticleEmitter;
  12343. /**
  12344. * Called by the GPUParticleSystem to setup the update shader
  12345. * @param effect defines the update shader
  12346. */
  12347. applyToShader(effect: Effect): void;
  12348. /**
  12349. * Returns a string to use to update the GPU particles update shader
  12350. * @returns a string containng the defines string
  12351. */
  12352. getEffectDefines(): string;
  12353. /**
  12354. * Returns the string "CylinderParticleEmitter"
  12355. * @returns a string containing the class name
  12356. */
  12357. getClassName(): string;
  12358. /**
  12359. * Serializes the particle system to a JSON object.
  12360. * @returns the JSON object
  12361. */
  12362. serialize(): any;
  12363. /**
  12364. * Parse properties from a JSON object
  12365. * @param serializationObject defines the JSON object
  12366. */
  12367. parse(serializationObject: any): void;
  12368. }
  12369. /**
  12370. * Particle emitter emitting particles from the inside of a cylinder.
  12371. * It emits the particles randomly between two vectors.
  12372. */
  12373. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12374. /**
  12375. * The min limit of the emission direction.
  12376. */
  12377. direction1: Vector3;
  12378. /**
  12379. * The max limit of the emission direction.
  12380. */
  12381. direction2: Vector3;
  12382. /**
  12383. * Creates a new instance CylinderDirectedParticleEmitter
  12384. * @param radius the radius of the emission cylinder (1 by default)
  12385. * @param height the height of the emission cylinder (1 by default)
  12386. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12387. * @param direction1 the min limit of the emission direction (up vector by default)
  12388. * @param direction2 the max limit of the emission direction (up vector by default)
  12389. */
  12390. constructor(radius?: number, height?: number, radiusRange?: number,
  12391. /**
  12392. * The min limit of the emission direction.
  12393. */
  12394. direction1?: Vector3,
  12395. /**
  12396. * The max limit of the emission direction.
  12397. */
  12398. direction2?: Vector3);
  12399. /**
  12400. * Called by the particle System when the direction is computed for the created particle.
  12401. * @param worldMatrix is the world matrix of the particle system
  12402. * @param directionToUpdate is the direction vector to update with the result
  12403. * @param particle is the particle we are computed the direction for
  12404. */
  12405. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12406. /**
  12407. * Clones the current emitter and returns a copy of it
  12408. * @returns the new emitter
  12409. */
  12410. clone(): CylinderDirectedParticleEmitter;
  12411. /**
  12412. * Called by the GPUParticleSystem to setup the update shader
  12413. * @param effect defines the update shader
  12414. */
  12415. applyToShader(effect: Effect): void;
  12416. /**
  12417. * Returns a string to use to update the GPU particles update shader
  12418. * @returns a string containng the defines string
  12419. */
  12420. getEffectDefines(): string;
  12421. /**
  12422. * Returns the string "CylinderDirectedParticleEmitter"
  12423. * @returns a string containing the class name
  12424. */
  12425. getClassName(): string;
  12426. /**
  12427. * Serializes the particle system to a JSON object.
  12428. * @returns the JSON object
  12429. */
  12430. serialize(): any;
  12431. /**
  12432. * Parse properties from a JSON object
  12433. * @param serializationObject defines the JSON object
  12434. */
  12435. parse(serializationObject: any): void;
  12436. }
  12437. }
  12438. declare module BABYLON {
  12439. /**
  12440. * Particle emitter emitting particles from the inside of a hemisphere.
  12441. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12442. */
  12443. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12444. /**
  12445. * The radius of the emission hemisphere.
  12446. */
  12447. radius: number;
  12448. /**
  12449. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12450. */
  12451. radiusRange: number;
  12452. /**
  12453. * How much to randomize the particle direction [0-1].
  12454. */
  12455. directionRandomizer: number;
  12456. /**
  12457. * Creates a new instance HemisphericParticleEmitter
  12458. * @param radius the radius of the emission hemisphere (1 by default)
  12459. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12460. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12461. */
  12462. constructor(
  12463. /**
  12464. * The radius of the emission hemisphere.
  12465. */
  12466. radius?: number,
  12467. /**
  12468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12469. */
  12470. radiusRange?: number,
  12471. /**
  12472. * How much to randomize the particle direction [0-1].
  12473. */
  12474. directionRandomizer?: number);
  12475. /**
  12476. * Called by the particle System when the direction is computed for the created particle.
  12477. * @param worldMatrix is the world matrix of the particle system
  12478. * @param directionToUpdate is the direction vector to update with the result
  12479. * @param particle is the particle we are computed the direction for
  12480. */
  12481. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12482. /**
  12483. * Called by the particle System when the position is computed for the created particle.
  12484. * @param worldMatrix is the world matrix of the particle system
  12485. * @param positionToUpdate is the position vector to update with the result
  12486. * @param particle is the particle we are computed the position for
  12487. */
  12488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12489. /**
  12490. * Clones the current emitter and returns a copy of it
  12491. * @returns the new emitter
  12492. */
  12493. clone(): HemisphericParticleEmitter;
  12494. /**
  12495. * Called by the GPUParticleSystem to setup the update shader
  12496. * @param effect defines the update shader
  12497. */
  12498. applyToShader(effect: Effect): void;
  12499. /**
  12500. * Returns a string to use to update the GPU particles update shader
  12501. * @returns a string containng the defines string
  12502. */
  12503. getEffectDefines(): string;
  12504. /**
  12505. * Returns the string "HemisphericParticleEmitter"
  12506. * @returns a string containing the class name
  12507. */
  12508. getClassName(): string;
  12509. /**
  12510. * Serializes the particle system to a JSON object.
  12511. * @returns the JSON object
  12512. */
  12513. serialize(): any;
  12514. /**
  12515. * Parse properties from a JSON object
  12516. * @param serializationObject defines the JSON object
  12517. */
  12518. parse(serializationObject: any): void;
  12519. }
  12520. }
  12521. declare module BABYLON {
  12522. /**
  12523. * Particle emitter emitting particles from a point.
  12524. * It emits the particles randomly between 2 given directions.
  12525. */
  12526. export class PointParticleEmitter implements IParticleEmitterType {
  12527. /**
  12528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12529. */
  12530. direction1: Vector3;
  12531. /**
  12532. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12533. */
  12534. direction2: Vector3;
  12535. /**
  12536. * Creates a new instance PointParticleEmitter
  12537. */
  12538. constructor();
  12539. /**
  12540. * Called by the particle System when the direction is computed for the created particle.
  12541. * @param worldMatrix is the world matrix of the particle system
  12542. * @param directionToUpdate is the direction vector to update with the result
  12543. * @param particle is the particle we are computed the direction for
  12544. */
  12545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12546. /**
  12547. * Called by the particle System when the position is computed for the created particle.
  12548. * @param worldMatrix is the world matrix of the particle system
  12549. * @param positionToUpdate is the position vector to update with the result
  12550. * @param particle is the particle we are computed the position for
  12551. */
  12552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12553. /**
  12554. * Clones the current emitter and returns a copy of it
  12555. * @returns the new emitter
  12556. */
  12557. clone(): PointParticleEmitter;
  12558. /**
  12559. * Called by the GPUParticleSystem to setup the update shader
  12560. * @param effect defines the update shader
  12561. */
  12562. applyToShader(effect: Effect): void;
  12563. /**
  12564. * Returns a string to use to update the GPU particles update shader
  12565. * @returns a string containng the defines string
  12566. */
  12567. getEffectDefines(): string;
  12568. /**
  12569. * Returns the string "PointParticleEmitter"
  12570. * @returns a string containing the class name
  12571. */
  12572. getClassName(): string;
  12573. /**
  12574. * Serializes the particle system to a JSON object.
  12575. * @returns the JSON object
  12576. */
  12577. serialize(): any;
  12578. /**
  12579. * Parse properties from a JSON object
  12580. * @param serializationObject defines the JSON object
  12581. */
  12582. parse(serializationObject: any): void;
  12583. }
  12584. }
  12585. declare module BABYLON {
  12586. /**
  12587. * Particle emitter emitting particles from the inside of a sphere.
  12588. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12589. */
  12590. export class SphereParticleEmitter implements IParticleEmitterType {
  12591. /**
  12592. * The radius of the emission sphere.
  12593. */
  12594. radius: number;
  12595. /**
  12596. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12597. */
  12598. radiusRange: number;
  12599. /**
  12600. * How much to randomize the particle direction [0-1].
  12601. */
  12602. directionRandomizer: number;
  12603. /**
  12604. * Creates a new instance SphereParticleEmitter
  12605. * @param radius the radius of the emission sphere (1 by default)
  12606. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12607. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12608. */
  12609. constructor(
  12610. /**
  12611. * The radius of the emission sphere.
  12612. */
  12613. radius?: number,
  12614. /**
  12615. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12616. */
  12617. radiusRange?: number,
  12618. /**
  12619. * How much to randomize the particle direction [0-1].
  12620. */
  12621. directionRandomizer?: number);
  12622. /**
  12623. * Called by the particle System when the direction is computed for the created particle.
  12624. * @param worldMatrix is the world matrix of the particle system
  12625. * @param directionToUpdate is the direction vector to update with the result
  12626. * @param particle is the particle we are computed the direction for
  12627. */
  12628. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12629. /**
  12630. * Called by the particle System when the position is computed for the created particle.
  12631. * @param worldMatrix is the world matrix of the particle system
  12632. * @param positionToUpdate is the position vector to update with the result
  12633. * @param particle is the particle we are computed the position for
  12634. */
  12635. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12636. /**
  12637. * Clones the current emitter and returns a copy of it
  12638. * @returns the new emitter
  12639. */
  12640. clone(): SphereParticleEmitter;
  12641. /**
  12642. * Called by the GPUParticleSystem to setup the update shader
  12643. * @param effect defines the update shader
  12644. */
  12645. applyToShader(effect: Effect): void;
  12646. /**
  12647. * Returns a string to use to update the GPU particles update shader
  12648. * @returns a string containng the defines string
  12649. */
  12650. getEffectDefines(): string;
  12651. /**
  12652. * Returns the string "SphereParticleEmitter"
  12653. * @returns a string containing the class name
  12654. */
  12655. getClassName(): string;
  12656. /**
  12657. * Serializes the particle system to a JSON object.
  12658. * @returns the JSON object
  12659. */
  12660. serialize(): any;
  12661. /**
  12662. * Parse properties from a JSON object
  12663. * @param serializationObject defines the JSON object
  12664. */
  12665. parse(serializationObject: any): void;
  12666. }
  12667. /**
  12668. * Particle emitter emitting particles from the inside of a sphere.
  12669. * It emits the particles randomly between two vectors.
  12670. */
  12671. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12672. /**
  12673. * The min limit of the emission direction.
  12674. */
  12675. direction1: Vector3;
  12676. /**
  12677. * The max limit of the emission direction.
  12678. */
  12679. direction2: Vector3;
  12680. /**
  12681. * Creates a new instance SphereDirectedParticleEmitter
  12682. * @param radius the radius of the emission sphere (1 by default)
  12683. * @param direction1 the min limit of the emission direction (up vector by default)
  12684. * @param direction2 the max limit of the emission direction (up vector by default)
  12685. */
  12686. constructor(radius?: number,
  12687. /**
  12688. * The min limit of the emission direction.
  12689. */
  12690. direction1?: Vector3,
  12691. /**
  12692. * The max limit of the emission direction.
  12693. */
  12694. direction2?: Vector3);
  12695. /**
  12696. * Called by the particle System when the direction is computed for the created particle.
  12697. * @param worldMatrix is the world matrix of the particle system
  12698. * @param directionToUpdate is the direction vector to update with the result
  12699. * @param particle is the particle we are computed the direction for
  12700. */
  12701. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12702. /**
  12703. * Clones the current emitter and returns a copy of it
  12704. * @returns the new emitter
  12705. */
  12706. clone(): SphereDirectedParticleEmitter;
  12707. /**
  12708. * Called by the GPUParticleSystem to setup the update shader
  12709. * @param effect defines the update shader
  12710. */
  12711. applyToShader(effect: Effect): void;
  12712. /**
  12713. * Returns a string to use to update the GPU particles update shader
  12714. * @returns a string containng the defines string
  12715. */
  12716. getEffectDefines(): string;
  12717. /**
  12718. * Returns the string "SphereDirectedParticleEmitter"
  12719. * @returns a string containing the class name
  12720. */
  12721. getClassName(): string;
  12722. /**
  12723. * Serializes the particle system to a JSON object.
  12724. * @returns the JSON object
  12725. */
  12726. serialize(): any;
  12727. /**
  12728. * Parse properties from a JSON object
  12729. * @param serializationObject defines the JSON object
  12730. */
  12731. parse(serializationObject: any): void;
  12732. }
  12733. }
  12734. declare module BABYLON {
  12735. /**
  12736. * Particle emitter emitting particles from a custom list of positions.
  12737. */
  12738. export class CustomParticleEmitter implements IParticleEmitterType {
  12739. /**
  12740. * Gets or sets the position generator that will create the inital position of each particle.
  12741. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12742. */
  12743. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12744. /**
  12745. * Gets or sets the destination generator that will create the final destination of each particle.
  12746. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12747. */
  12748. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12749. /**
  12750. * Creates a new instance CustomParticleEmitter
  12751. */
  12752. constructor();
  12753. /**
  12754. * Called by the particle System when the direction is computed for the created particle.
  12755. * @param worldMatrix is the world matrix of the particle system
  12756. * @param directionToUpdate is the direction vector to update with the result
  12757. * @param particle is the particle we are computed the direction for
  12758. */
  12759. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12760. /**
  12761. * Called by the particle System when the position is computed for the created particle.
  12762. * @param worldMatrix is the world matrix of the particle system
  12763. * @param positionToUpdate is the position vector to update with the result
  12764. * @param particle is the particle we are computed the position for
  12765. */
  12766. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12767. /**
  12768. * Clones the current emitter and returns a copy of it
  12769. * @returns the new emitter
  12770. */
  12771. clone(): CustomParticleEmitter;
  12772. /**
  12773. * Called by the GPUParticleSystem to setup the update shader
  12774. * @param effect defines the update shader
  12775. */
  12776. applyToShader(effect: Effect): void;
  12777. /**
  12778. * Returns a string to use to update the GPU particles update shader
  12779. * @returns a string containng the defines string
  12780. */
  12781. getEffectDefines(): string;
  12782. /**
  12783. * Returns the string "PointParticleEmitter"
  12784. * @returns a string containing the class name
  12785. */
  12786. getClassName(): string;
  12787. /**
  12788. * Serializes the particle system to a JSON object.
  12789. * @returns the JSON object
  12790. */
  12791. serialize(): any;
  12792. /**
  12793. * Parse properties from a JSON object
  12794. * @param serializationObject defines the JSON object
  12795. */
  12796. parse(serializationObject: any): void;
  12797. }
  12798. }
  12799. declare module BABYLON {
  12800. /**
  12801. * Particle emitter emitting particles from the inside of a box.
  12802. * It emits the particles randomly between 2 given directions.
  12803. */
  12804. export class MeshParticleEmitter implements IParticleEmitterType {
  12805. /** Defines the mesh to use as source */
  12806. mesh?: AbstractMesh | undefined;
  12807. private _indices;
  12808. private _positions;
  12809. private _normals;
  12810. private _storedNormal;
  12811. /**
  12812. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12813. */
  12814. direction1: Vector3;
  12815. /**
  12816. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12817. */
  12818. direction2: Vector3;
  12819. /**
  12820. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12821. */
  12822. useMeshNormalsForDirection: boolean;
  12823. /**
  12824. * Creates a new instance MeshParticleEmitter
  12825. * @param mesh defines the mesh to use as source
  12826. */
  12827. constructor(
  12828. /** Defines the mesh to use as source */
  12829. mesh?: AbstractMesh | undefined);
  12830. /**
  12831. * Called by the particle System when the direction is computed for the created particle.
  12832. * @param worldMatrix is the world matrix of the particle system
  12833. * @param directionToUpdate is the direction vector to update with the result
  12834. * @param particle is the particle we are computed the direction for
  12835. */
  12836. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12837. /**
  12838. * Called by the particle System when the position is computed for the created particle.
  12839. * @param worldMatrix is the world matrix of the particle system
  12840. * @param positionToUpdate is the position vector to update with the result
  12841. * @param particle is the particle we are computed the position for
  12842. */
  12843. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12844. /**
  12845. * Clones the current emitter and returns a copy of it
  12846. * @returns the new emitter
  12847. */
  12848. clone(): MeshParticleEmitter;
  12849. /**
  12850. * Called by the GPUParticleSystem to setup the update shader
  12851. * @param effect defines the update shader
  12852. */
  12853. applyToShader(effect: Effect): void;
  12854. /**
  12855. * Returns a string to use to update the GPU particles update shader
  12856. * @returns a string containng the defines string
  12857. */
  12858. getEffectDefines(): string;
  12859. /**
  12860. * Returns the string "BoxParticleEmitter"
  12861. * @returns a string containing the class name
  12862. */
  12863. getClassName(): string;
  12864. /**
  12865. * Serializes the particle system to a JSON object.
  12866. * @returns the JSON object
  12867. */
  12868. serialize(): any;
  12869. /**
  12870. * Parse properties from a JSON object
  12871. * @param serializationObject defines the JSON object
  12872. * @param scene defines the hosting scene
  12873. */
  12874. parse(serializationObject: any, scene: Scene): void;
  12875. }
  12876. }
  12877. declare module BABYLON {
  12878. /**
  12879. * Interface representing a particle system in Babylon.js.
  12880. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12881. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12882. */
  12883. export interface IParticleSystem {
  12884. /**
  12885. * List of animations used by the particle system.
  12886. */
  12887. animations: Animation[];
  12888. /**
  12889. * The id of the Particle system.
  12890. */
  12891. id: string;
  12892. /**
  12893. * The name of the Particle system.
  12894. */
  12895. name: string;
  12896. /**
  12897. * The emitter represents the Mesh or position we are attaching the particle system to.
  12898. */
  12899. emitter: Nullable<AbstractMesh | Vector3>;
  12900. /**
  12901. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12902. */
  12903. isBillboardBased: boolean;
  12904. /**
  12905. * The rendering group used by the Particle system to chose when to render.
  12906. */
  12907. renderingGroupId: number;
  12908. /**
  12909. * The layer mask we are rendering the particles through.
  12910. */
  12911. layerMask: number;
  12912. /**
  12913. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12914. */
  12915. updateSpeed: number;
  12916. /**
  12917. * The amount of time the particle system is running (depends of the overall update speed).
  12918. */
  12919. targetStopDuration: number;
  12920. /**
  12921. * The texture used to render each particle. (this can be a spritesheet)
  12922. */
  12923. particleTexture: Nullable<Texture>;
  12924. /**
  12925. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12926. */
  12927. blendMode: number;
  12928. /**
  12929. * Minimum life time of emitting particles.
  12930. */
  12931. minLifeTime: number;
  12932. /**
  12933. * Maximum life time of emitting particles.
  12934. */
  12935. maxLifeTime: number;
  12936. /**
  12937. * Minimum Size of emitting particles.
  12938. */
  12939. minSize: number;
  12940. /**
  12941. * Maximum Size of emitting particles.
  12942. */
  12943. maxSize: number;
  12944. /**
  12945. * Minimum scale of emitting particles on X axis.
  12946. */
  12947. minScaleX: number;
  12948. /**
  12949. * Maximum scale of emitting particles on X axis.
  12950. */
  12951. maxScaleX: number;
  12952. /**
  12953. * Minimum scale of emitting particles on Y axis.
  12954. */
  12955. minScaleY: number;
  12956. /**
  12957. * Maximum scale of emitting particles on Y axis.
  12958. */
  12959. maxScaleY: number;
  12960. /**
  12961. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12962. */
  12963. color1: Color4;
  12964. /**
  12965. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12966. */
  12967. color2: Color4;
  12968. /**
  12969. * Color the particle will have at the end of its lifetime.
  12970. */
  12971. colorDead: Color4;
  12972. /**
  12973. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12974. */
  12975. emitRate: number;
  12976. /**
  12977. * You can use gravity if you want to give an orientation to your particles.
  12978. */
  12979. gravity: Vector3;
  12980. /**
  12981. * Minimum power of emitting particles.
  12982. */
  12983. minEmitPower: number;
  12984. /**
  12985. * Maximum power of emitting particles.
  12986. */
  12987. maxEmitPower: number;
  12988. /**
  12989. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12990. */
  12991. minAngularSpeed: number;
  12992. /**
  12993. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12994. */
  12995. maxAngularSpeed: number;
  12996. /**
  12997. * Gets or sets the minimal initial rotation in radians.
  12998. */
  12999. minInitialRotation: number;
  13000. /**
  13001. * Gets or sets the maximal initial rotation in radians.
  13002. */
  13003. maxInitialRotation: number;
  13004. /**
  13005. * The particle emitter type defines the emitter used by the particle system.
  13006. * It can be for example box, sphere, or cone...
  13007. */
  13008. particleEmitterType: Nullable<IParticleEmitterType>;
  13009. /**
  13010. * Defines the delay in milliseconds before starting the system (0 by default)
  13011. */
  13012. startDelay: number;
  13013. /**
  13014. * 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
  13015. */
  13016. preWarmCycles: number;
  13017. /**
  13018. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13019. */
  13020. preWarmStepOffset: number;
  13021. /**
  13022. * 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)
  13023. */
  13024. spriteCellChangeSpeed: number;
  13025. /**
  13026. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13027. */
  13028. startSpriteCellID: number;
  13029. /**
  13030. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13031. */
  13032. endSpriteCellID: number;
  13033. /**
  13034. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13035. */
  13036. spriteCellWidth: number;
  13037. /**
  13038. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13039. */
  13040. spriteCellHeight: number;
  13041. /**
  13042. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13043. */
  13044. spriteRandomStartCell: boolean;
  13045. /**
  13046. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13047. */
  13048. isAnimationSheetEnabled: boolean;
  13049. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13050. translationPivot: Vector2;
  13051. /**
  13052. * Gets or sets a texture used to add random noise to particle positions
  13053. */
  13054. noiseTexture: Nullable<BaseTexture>;
  13055. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13056. noiseStrength: Vector3;
  13057. /**
  13058. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13059. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13060. */
  13061. billboardMode: number;
  13062. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13063. limitVelocityDamping: number;
  13064. /**
  13065. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13066. */
  13067. beginAnimationOnStart: boolean;
  13068. /**
  13069. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13070. */
  13071. beginAnimationFrom: number;
  13072. /**
  13073. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13074. */
  13075. beginAnimationTo: number;
  13076. /**
  13077. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13078. */
  13079. beginAnimationLoop: boolean;
  13080. /**
  13081. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13082. */
  13083. disposeOnStop: boolean;
  13084. /**
  13085. * Gets the maximum number of particles active at the same time.
  13086. * @returns The max number of active particles.
  13087. */
  13088. getCapacity(): number;
  13089. /**
  13090. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13091. * @returns True if it has been started, otherwise false.
  13092. */
  13093. isStarted(): boolean;
  13094. /**
  13095. * Animates the particle system for this frame.
  13096. */
  13097. animate(): void;
  13098. /**
  13099. * Renders the particle system in its current state.
  13100. * @returns the current number of particles
  13101. */
  13102. render(): number;
  13103. /**
  13104. * Dispose the particle system and frees its associated resources.
  13105. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13106. */
  13107. dispose(disposeTexture?: boolean): void;
  13108. /**
  13109. * Clones the particle system.
  13110. * @param name The name of the cloned object
  13111. * @param newEmitter The new emitter to use
  13112. * @returns the cloned particle system
  13113. */
  13114. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13115. /**
  13116. * Serializes the particle system to a JSON object.
  13117. * @returns the JSON object
  13118. */
  13119. serialize(): any;
  13120. /**
  13121. * Rebuild the particle system
  13122. */
  13123. rebuild(): void;
  13124. /**
  13125. * Starts the particle system and begins to emit
  13126. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13127. */
  13128. start(delay?: number): void;
  13129. /**
  13130. * Stops the particle system.
  13131. */
  13132. stop(): void;
  13133. /**
  13134. * Remove all active particles
  13135. */
  13136. reset(): void;
  13137. /**
  13138. * Is this system ready to be used/rendered
  13139. * @return true if the system is ready
  13140. */
  13141. isReady(): boolean;
  13142. /**
  13143. * Adds a new color gradient
  13144. * @param gradient defines the gradient to use (between 0 and 1)
  13145. * @param color1 defines the color to affect to the specified gradient
  13146. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13147. * @returns the current particle system
  13148. */
  13149. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13150. /**
  13151. * Remove a specific color gradient
  13152. * @param gradient defines the gradient to remove
  13153. * @returns the current particle system
  13154. */
  13155. removeColorGradient(gradient: number): IParticleSystem;
  13156. /**
  13157. * Adds a new size gradient
  13158. * @param gradient defines the gradient to use (between 0 and 1)
  13159. * @param factor defines the size factor to affect to the specified gradient
  13160. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13161. * @returns the current particle system
  13162. */
  13163. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13164. /**
  13165. * Remove a specific size gradient
  13166. * @param gradient defines the gradient to remove
  13167. * @returns the current particle system
  13168. */
  13169. removeSizeGradient(gradient: number): IParticleSystem;
  13170. /**
  13171. * Gets the current list of color gradients.
  13172. * You must use addColorGradient and removeColorGradient to udpate this list
  13173. * @returns the list of color gradients
  13174. */
  13175. getColorGradients(): Nullable<Array<ColorGradient>>;
  13176. /**
  13177. * Gets the current list of size gradients.
  13178. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13179. * @returns the list of size gradients
  13180. */
  13181. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13182. /**
  13183. * Gets the current list of angular speed gradients.
  13184. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13185. * @returns the list of angular speed gradients
  13186. */
  13187. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13188. /**
  13189. * Adds a new angular speed gradient
  13190. * @param gradient defines the gradient to use (between 0 and 1)
  13191. * @param factor defines the angular speed to affect to the specified gradient
  13192. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13193. * @returns the current particle system
  13194. */
  13195. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13196. /**
  13197. * Remove a specific angular speed gradient
  13198. * @param gradient defines the gradient to remove
  13199. * @returns the current particle system
  13200. */
  13201. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13202. /**
  13203. * Gets the current list of velocity gradients.
  13204. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13205. * @returns the list of velocity gradients
  13206. */
  13207. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13208. /**
  13209. * Adds a new velocity gradient
  13210. * @param gradient defines the gradient to use (between 0 and 1)
  13211. * @param factor defines the velocity to affect to the specified gradient
  13212. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13213. * @returns the current particle system
  13214. */
  13215. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13216. /**
  13217. * Remove a specific velocity gradient
  13218. * @param gradient defines the gradient to remove
  13219. * @returns the current particle system
  13220. */
  13221. removeVelocityGradient(gradient: number): IParticleSystem;
  13222. /**
  13223. * Gets the current list of limit velocity gradients.
  13224. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13225. * @returns the list of limit velocity gradients
  13226. */
  13227. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13228. /**
  13229. * Adds a new limit velocity gradient
  13230. * @param gradient defines the gradient to use (between 0 and 1)
  13231. * @param factor defines the limit velocity to affect to the specified gradient
  13232. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13233. * @returns the current particle system
  13234. */
  13235. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13236. /**
  13237. * Remove a specific limit velocity gradient
  13238. * @param gradient defines the gradient to remove
  13239. * @returns the current particle system
  13240. */
  13241. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13242. /**
  13243. * Adds a new drag gradient
  13244. * @param gradient defines the gradient to use (between 0 and 1)
  13245. * @param factor defines the drag to affect to the specified gradient
  13246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13247. * @returns the current particle system
  13248. */
  13249. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13250. /**
  13251. * Remove a specific drag gradient
  13252. * @param gradient defines the gradient to remove
  13253. * @returns the current particle system
  13254. */
  13255. removeDragGradient(gradient: number): IParticleSystem;
  13256. /**
  13257. * Gets the current list of drag gradients.
  13258. * You must use addDragGradient and removeDragGradient to udpate this list
  13259. * @returns the list of drag gradients
  13260. */
  13261. getDragGradients(): Nullable<Array<FactorGradient>>;
  13262. /**
  13263. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13264. * @param gradient defines the gradient to use (between 0 and 1)
  13265. * @param factor defines the emit rate to affect to the specified gradient
  13266. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13267. * @returns the current particle system
  13268. */
  13269. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13270. /**
  13271. * Remove a specific emit rate gradient
  13272. * @param gradient defines the gradient to remove
  13273. * @returns the current particle system
  13274. */
  13275. removeEmitRateGradient(gradient: number): IParticleSystem;
  13276. /**
  13277. * Gets the current list of emit rate gradients.
  13278. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13279. * @returns the list of emit rate gradients
  13280. */
  13281. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13282. /**
  13283. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13284. * @param gradient defines the gradient to use (between 0 and 1)
  13285. * @param factor defines the start size to affect to the specified gradient
  13286. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13287. * @returns the current particle system
  13288. */
  13289. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13290. /**
  13291. * Remove a specific start size gradient
  13292. * @param gradient defines the gradient to remove
  13293. * @returns the current particle system
  13294. */
  13295. removeStartSizeGradient(gradient: number): IParticleSystem;
  13296. /**
  13297. * Gets the current list of start size gradients.
  13298. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13299. * @returns the list of start size gradients
  13300. */
  13301. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13302. /**
  13303. * Adds a new life time gradient
  13304. * @param gradient defines the gradient to use (between 0 and 1)
  13305. * @param factor defines the life time factor to affect to the specified gradient
  13306. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13307. * @returns the current particle system
  13308. */
  13309. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13310. /**
  13311. * Remove a specific life time gradient
  13312. * @param gradient defines the gradient to remove
  13313. * @returns the current particle system
  13314. */
  13315. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13316. /**
  13317. * Gets the current list of life time gradients.
  13318. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13319. * @returns the list of life time gradients
  13320. */
  13321. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13322. /**
  13323. * Gets the current list of color gradients.
  13324. * You must use addColorGradient and removeColorGradient to udpate this list
  13325. * @returns the list of color gradients
  13326. */
  13327. getColorGradients(): Nullable<Array<ColorGradient>>;
  13328. /**
  13329. * Adds a new ramp gradient used to remap particle colors
  13330. * @param gradient defines the gradient to use (between 0 and 1)
  13331. * @param color defines the color to affect to the specified gradient
  13332. * @returns the current particle system
  13333. */
  13334. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13335. /**
  13336. * Gets the current list of ramp gradients.
  13337. * You must use addRampGradient and removeRampGradient to udpate this list
  13338. * @returns the list of ramp gradients
  13339. */
  13340. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13341. /** Gets or sets a boolean indicating that ramp gradients must be used
  13342. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13343. */
  13344. useRampGradients: boolean;
  13345. /**
  13346. * Adds a new color remap gradient
  13347. * @param gradient defines the gradient to use (between 0 and 1)
  13348. * @param min defines the color remap minimal range
  13349. * @param max defines the color remap maximal range
  13350. * @returns the current particle system
  13351. */
  13352. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13353. /**
  13354. * Gets the current list of color remap gradients.
  13355. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13356. * @returns the list of color remap gradients
  13357. */
  13358. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13359. /**
  13360. * Adds a new alpha remap gradient
  13361. * @param gradient defines the gradient to use (between 0 and 1)
  13362. * @param min defines the alpha remap minimal range
  13363. * @param max defines the alpha remap maximal range
  13364. * @returns the current particle system
  13365. */
  13366. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13367. /**
  13368. * Gets the current list of alpha remap gradients.
  13369. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13370. * @returns the list of alpha remap gradients
  13371. */
  13372. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13373. /**
  13374. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13375. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13376. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13377. * @returns the emitter
  13378. */
  13379. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13380. /**
  13381. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13382. * @param radius The radius of the hemisphere to emit from
  13383. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13384. * @returns the emitter
  13385. */
  13386. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13387. /**
  13388. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13389. * @param radius The radius of the sphere to emit from
  13390. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13391. * @returns the emitter
  13392. */
  13393. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13394. /**
  13395. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13396. * @param radius The radius of the sphere to emit from
  13397. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13398. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13399. * @returns the emitter
  13400. */
  13401. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13402. /**
  13403. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13404. * @param radius The radius of the emission cylinder
  13405. * @param height The height of the emission cylinder
  13406. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13407. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13408. * @returns the emitter
  13409. */
  13410. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13411. /**
  13412. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13413. * @param radius The radius of the cylinder to emit from
  13414. * @param height The height of the emission cylinder
  13415. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13416. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13417. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13418. * @returns the emitter
  13419. */
  13420. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13421. /**
  13422. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13423. * @param radius The radius of the cone to emit from
  13424. * @param angle The base angle of the cone
  13425. * @returns the emitter
  13426. */
  13427. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13428. /**
  13429. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13430. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13431. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13432. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13433. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13434. * @returns the emitter
  13435. */
  13436. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13437. /**
  13438. * Get hosting scene
  13439. * @returns the scene
  13440. */
  13441. getScene(): Scene;
  13442. }
  13443. }
  13444. declare module BABYLON {
  13445. /**
  13446. * 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.
  13447. * @see https://doc.babylonjs.com/how_to/transformnode
  13448. */
  13449. export class TransformNode extends Node {
  13450. /**
  13451. * Object will not rotate to face the camera
  13452. */
  13453. static BILLBOARDMODE_NONE: number;
  13454. /**
  13455. * Object will rotate to face the camera but only on the x axis
  13456. */
  13457. static BILLBOARDMODE_X: number;
  13458. /**
  13459. * Object will rotate to face the camera but only on the y axis
  13460. */
  13461. static BILLBOARDMODE_Y: number;
  13462. /**
  13463. * Object will rotate to face the camera but only on the z axis
  13464. */
  13465. static BILLBOARDMODE_Z: number;
  13466. /**
  13467. * Object will rotate to face the camera
  13468. */
  13469. static BILLBOARDMODE_ALL: number;
  13470. /**
  13471. * Object will rotate to face the camera's position instead of orientation
  13472. */
  13473. static BILLBOARDMODE_USE_POSITION: number;
  13474. private _forward;
  13475. private _forwardInverted;
  13476. private _up;
  13477. private _right;
  13478. private _rightInverted;
  13479. private _position;
  13480. private _rotation;
  13481. private _rotationQuaternion;
  13482. protected _scaling: Vector3;
  13483. protected _isDirty: boolean;
  13484. private _transformToBoneReferal;
  13485. private _isAbsoluteSynced;
  13486. private _billboardMode;
  13487. /**
  13488. * Gets or sets the billboard mode. Default is 0.
  13489. *
  13490. * | Value | Type | Description |
  13491. * | --- | --- | --- |
  13492. * | 0 | BILLBOARDMODE_NONE | |
  13493. * | 1 | BILLBOARDMODE_X | |
  13494. * | 2 | BILLBOARDMODE_Y | |
  13495. * | 4 | BILLBOARDMODE_Z | |
  13496. * | 7 | BILLBOARDMODE_ALL | |
  13497. *
  13498. */
  13499. get billboardMode(): number;
  13500. set billboardMode(value: number);
  13501. private _preserveParentRotationForBillboard;
  13502. /**
  13503. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13504. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13505. */
  13506. get preserveParentRotationForBillboard(): boolean;
  13507. set preserveParentRotationForBillboard(value: boolean);
  13508. /**
  13509. * 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
  13510. */
  13511. scalingDeterminant: number;
  13512. private _infiniteDistance;
  13513. /**
  13514. * Gets or sets the distance of the object to max, often used by skybox
  13515. */
  13516. get infiniteDistance(): boolean;
  13517. set infiniteDistance(value: boolean);
  13518. /**
  13519. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13520. * By default the system will update normals to compensate
  13521. */
  13522. ignoreNonUniformScaling: boolean;
  13523. /**
  13524. * 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
  13525. */
  13526. reIntegrateRotationIntoRotationQuaternion: boolean;
  13527. /** @hidden */
  13528. _poseMatrix: Nullable<Matrix>;
  13529. /** @hidden */
  13530. _localMatrix: Matrix;
  13531. private _usePivotMatrix;
  13532. private _absolutePosition;
  13533. private _absoluteScaling;
  13534. private _absoluteRotationQuaternion;
  13535. private _pivotMatrix;
  13536. private _pivotMatrixInverse;
  13537. protected _postMultiplyPivotMatrix: boolean;
  13538. protected _isWorldMatrixFrozen: boolean;
  13539. /** @hidden */
  13540. _indexInSceneTransformNodesArray: number;
  13541. /**
  13542. * An event triggered after the world matrix is updated
  13543. */
  13544. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13545. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13546. /**
  13547. * Gets a string identifying the name of the class
  13548. * @returns "TransformNode" string
  13549. */
  13550. getClassName(): string;
  13551. /**
  13552. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13553. */
  13554. get position(): Vector3;
  13555. set position(newPosition: Vector3);
  13556. /**
  13557. * 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)).
  13558. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13559. */
  13560. get rotation(): Vector3;
  13561. set rotation(newRotation: Vector3);
  13562. /**
  13563. * 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)).
  13564. */
  13565. get scaling(): Vector3;
  13566. set scaling(newScaling: Vector3);
  13567. /**
  13568. * 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).
  13569. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13570. */
  13571. get rotationQuaternion(): Nullable<Quaternion>;
  13572. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13573. /**
  13574. * The forward direction of that transform in world space.
  13575. */
  13576. get forward(): Vector3;
  13577. /**
  13578. * The up direction of that transform in world space.
  13579. */
  13580. get up(): Vector3;
  13581. /**
  13582. * The right direction of that transform in world space.
  13583. */
  13584. get right(): Vector3;
  13585. /**
  13586. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13587. * @param matrix the matrix to copy the pose from
  13588. * @returns this TransformNode.
  13589. */
  13590. updatePoseMatrix(matrix: Matrix): TransformNode;
  13591. /**
  13592. * Returns the mesh Pose matrix.
  13593. * @returns the pose matrix
  13594. */
  13595. getPoseMatrix(): Matrix;
  13596. /** @hidden */
  13597. _isSynchronized(): boolean;
  13598. /** @hidden */
  13599. _initCache(): void;
  13600. /**
  13601. * Flag the transform node as dirty (Forcing it to update everything)
  13602. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13603. * @returns this transform node
  13604. */
  13605. markAsDirty(property: string): TransformNode;
  13606. /**
  13607. * Returns the current mesh absolute position.
  13608. * Returns a Vector3.
  13609. */
  13610. get absolutePosition(): Vector3;
  13611. /**
  13612. * Returns the current mesh absolute scaling.
  13613. * Returns a Vector3.
  13614. */
  13615. get absoluteScaling(): Vector3;
  13616. /**
  13617. * Returns the current mesh absolute rotation.
  13618. * Returns a Quaternion.
  13619. */
  13620. get absoluteRotationQuaternion(): Quaternion;
  13621. /**
  13622. * Sets a new matrix to apply before all other transformation
  13623. * @param matrix defines the transform matrix
  13624. * @returns the current TransformNode
  13625. */
  13626. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13627. /**
  13628. * Sets a new pivot matrix to the current node
  13629. * @param matrix defines the new pivot matrix to use
  13630. * @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
  13631. * @returns the current TransformNode
  13632. */
  13633. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13634. /**
  13635. * Returns the mesh pivot matrix.
  13636. * Default : Identity.
  13637. * @returns the matrix
  13638. */
  13639. getPivotMatrix(): Matrix;
  13640. /**
  13641. * Instantiate (when possible) or clone that node with its hierarchy
  13642. * @param newParent defines the new parent to use for the instance (or clone)
  13643. * @param options defines options to configure how copy is done
  13644. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13645. * @returns an instance (or a clone) of the current node with its hiearchy
  13646. */
  13647. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13648. doNotInstantiate: boolean;
  13649. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13650. /**
  13651. * Prevents the World matrix to be computed any longer
  13652. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13653. * @returns the TransformNode.
  13654. */
  13655. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13656. /**
  13657. * Allows back the World matrix computation.
  13658. * @returns the TransformNode.
  13659. */
  13660. unfreezeWorldMatrix(): this;
  13661. /**
  13662. * True if the World matrix has been frozen.
  13663. */
  13664. get isWorldMatrixFrozen(): boolean;
  13665. /**
  13666. * Retuns the mesh absolute position in the World.
  13667. * @returns a Vector3.
  13668. */
  13669. getAbsolutePosition(): Vector3;
  13670. /**
  13671. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13672. * @param absolutePosition the absolute position to set
  13673. * @returns the TransformNode.
  13674. */
  13675. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13676. /**
  13677. * Sets the mesh position in its local space.
  13678. * @param vector3 the position to set in localspace
  13679. * @returns the TransformNode.
  13680. */
  13681. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13682. /**
  13683. * Returns the mesh position in the local space from the current World matrix values.
  13684. * @returns a new Vector3.
  13685. */
  13686. getPositionExpressedInLocalSpace(): Vector3;
  13687. /**
  13688. * Translates the mesh along the passed Vector3 in its local space.
  13689. * @param vector3 the distance to translate in localspace
  13690. * @returns the TransformNode.
  13691. */
  13692. locallyTranslate(vector3: Vector3): TransformNode;
  13693. private static _lookAtVectorCache;
  13694. /**
  13695. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13696. * @param targetPoint the position (must be in same space as current mesh) to look at
  13697. * @param yawCor optional yaw (y-axis) correction in radians
  13698. * @param pitchCor optional pitch (x-axis) correction in radians
  13699. * @param rollCor optional roll (z-axis) correction in radians
  13700. * @param space the choosen space of the target
  13701. * @returns the TransformNode.
  13702. */
  13703. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13704. /**
  13705. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13706. * This Vector3 is expressed in the World space.
  13707. * @param localAxis axis to rotate
  13708. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13709. */
  13710. getDirection(localAxis: Vector3): Vector3;
  13711. /**
  13712. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13713. * localAxis is expressed in the mesh local space.
  13714. * result is computed in the Wordl space from the mesh World matrix.
  13715. * @param localAxis axis to rotate
  13716. * @param result the resulting transformnode
  13717. * @returns this TransformNode.
  13718. */
  13719. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13720. /**
  13721. * Sets this transform node rotation to the given local axis.
  13722. * @param localAxis the axis in local space
  13723. * @param yawCor optional yaw (y-axis) correction in radians
  13724. * @param pitchCor optional pitch (x-axis) correction in radians
  13725. * @param rollCor optional roll (z-axis) correction in radians
  13726. * @returns this TransformNode
  13727. */
  13728. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13729. /**
  13730. * Sets a new pivot point to the current node
  13731. * @param point defines the new pivot point to use
  13732. * @param space defines if the point is in world or local space (local by default)
  13733. * @returns the current TransformNode
  13734. */
  13735. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13736. /**
  13737. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13738. * @returns the pivot point
  13739. */
  13740. getPivotPoint(): Vector3;
  13741. /**
  13742. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13743. * @param result the vector3 to store the result
  13744. * @returns this TransformNode.
  13745. */
  13746. getPivotPointToRef(result: Vector3): TransformNode;
  13747. /**
  13748. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13749. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13750. */
  13751. getAbsolutePivotPoint(): Vector3;
  13752. /**
  13753. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13754. * @param result vector3 to store the result
  13755. * @returns this TransformNode.
  13756. */
  13757. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13758. /**
  13759. * Defines the passed node as the parent of the current node.
  13760. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13761. * @see https://doc.babylonjs.com/how_to/parenting
  13762. * @param node the node ot set as the parent
  13763. * @returns this TransformNode.
  13764. */
  13765. setParent(node: Nullable<Node>): TransformNode;
  13766. private _nonUniformScaling;
  13767. /**
  13768. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13769. */
  13770. get nonUniformScaling(): boolean;
  13771. /** @hidden */
  13772. _updateNonUniformScalingState(value: boolean): boolean;
  13773. /**
  13774. * Attach the current TransformNode to another TransformNode associated with a bone
  13775. * @param bone Bone affecting the TransformNode
  13776. * @param affectedTransformNode TransformNode associated with the bone
  13777. * @returns this object
  13778. */
  13779. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13780. /**
  13781. * Detach the transform node if its associated with a bone
  13782. * @returns this object
  13783. */
  13784. detachFromBone(): TransformNode;
  13785. private static _rotationAxisCache;
  13786. /**
  13787. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13788. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13789. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13790. * The passed axis is also normalized.
  13791. * @param axis the axis to rotate around
  13792. * @param amount the amount to rotate in radians
  13793. * @param space Space to rotate in (Default: local)
  13794. * @returns the TransformNode.
  13795. */
  13796. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13797. /**
  13798. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13799. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13800. * The passed axis is also normalized. .
  13801. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13802. * @param point the point to rotate around
  13803. * @param axis the axis to rotate around
  13804. * @param amount the amount to rotate in radians
  13805. * @returns the TransformNode
  13806. */
  13807. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13808. /**
  13809. * Translates the mesh along the axis vector for the passed distance in the given space.
  13810. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13811. * @param axis the axis to translate in
  13812. * @param distance the distance to translate
  13813. * @param space Space to rotate in (Default: local)
  13814. * @returns the TransformNode.
  13815. */
  13816. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13817. /**
  13818. * Adds a rotation step to the mesh current rotation.
  13819. * x, y, z are Euler angles expressed in radians.
  13820. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13821. * This means this rotation is made in the mesh local space only.
  13822. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13823. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13824. * ```javascript
  13825. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13826. * ```
  13827. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13828. * 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.
  13829. * @param x Rotation to add
  13830. * @param y Rotation to add
  13831. * @param z Rotation to add
  13832. * @returns the TransformNode.
  13833. */
  13834. addRotation(x: number, y: number, z: number): TransformNode;
  13835. /**
  13836. * @hidden
  13837. */
  13838. protected _getEffectiveParent(): Nullable<Node>;
  13839. /**
  13840. * Computes the world matrix of the node
  13841. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13842. * @returns the world matrix
  13843. */
  13844. computeWorldMatrix(force?: boolean): Matrix;
  13845. /**
  13846. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13847. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13848. */
  13849. resetLocalMatrix(independentOfChildren?: boolean): void;
  13850. protected _afterComputeWorldMatrix(): void;
  13851. /**
  13852. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13853. * @param func callback function to add
  13854. *
  13855. * @returns the TransformNode.
  13856. */
  13857. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13858. /**
  13859. * Removes a registered callback function.
  13860. * @param func callback function to remove
  13861. * @returns the TransformNode.
  13862. */
  13863. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13864. /**
  13865. * Gets the position of the current mesh in camera space
  13866. * @param camera defines the camera to use
  13867. * @returns a position
  13868. */
  13869. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13870. /**
  13871. * Returns the distance from the mesh to the active camera
  13872. * @param camera defines the camera to use
  13873. * @returns the distance
  13874. */
  13875. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13876. /**
  13877. * Clone the current transform node
  13878. * @param name Name of the new clone
  13879. * @param newParent New parent for the clone
  13880. * @param doNotCloneChildren Do not clone children hierarchy
  13881. * @returns the new transform node
  13882. */
  13883. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13884. /**
  13885. * Serializes the objects information.
  13886. * @param currentSerializationObject defines the object to serialize in
  13887. * @returns the serialized object
  13888. */
  13889. serialize(currentSerializationObject?: any): any;
  13890. /**
  13891. * Returns a new TransformNode object parsed from the source provided.
  13892. * @param parsedTransformNode is the source.
  13893. * @param scene the scne the object belongs to
  13894. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13895. * @returns a new TransformNode object parsed from the source provided.
  13896. */
  13897. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13898. /**
  13899. * Get all child-transformNodes of this node
  13900. * @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
  13901. * @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
  13902. * @returns an array of TransformNode
  13903. */
  13904. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13905. /**
  13906. * Releases resources associated with this transform node.
  13907. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13908. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13909. */
  13910. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13911. /**
  13912. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13913. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13914. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13915. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13916. * @returns the current mesh
  13917. */
  13918. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13919. private _syncAbsoluteScalingAndRotation;
  13920. }
  13921. }
  13922. declare module BABYLON {
  13923. /**
  13924. * Class used to override all child animations of a given target
  13925. */
  13926. export class AnimationPropertiesOverride {
  13927. /**
  13928. * Gets or sets a value indicating if animation blending must be used
  13929. */
  13930. enableBlending: boolean;
  13931. /**
  13932. * Gets or sets the blending speed to use when enableBlending is true
  13933. */
  13934. blendingSpeed: number;
  13935. /**
  13936. * Gets or sets the default loop mode to use
  13937. */
  13938. loopMode: number;
  13939. }
  13940. }
  13941. declare module BABYLON {
  13942. /**
  13943. * Class used to store bone information
  13944. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13945. */
  13946. export class Bone extends Node {
  13947. /**
  13948. * defines the bone name
  13949. */
  13950. name: string;
  13951. private static _tmpVecs;
  13952. private static _tmpQuat;
  13953. private static _tmpMats;
  13954. /**
  13955. * Gets the list of child bones
  13956. */
  13957. children: Bone[];
  13958. /** Gets the animations associated with this bone */
  13959. animations: Animation[];
  13960. /**
  13961. * Gets or sets bone length
  13962. */
  13963. length: number;
  13964. /**
  13965. * @hidden Internal only
  13966. * Set this value to map this bone to a different index in the transform matrices
  13967. * Set this value to -1 to exclude the bone from the transform matrices
  13968. */
  13969. _index: Nullable<number>;
  13970. private _skeleton;
  13971. private _localMatrix;
  13972. private _restPose;
  13973. private _baseMatrix;
  13974. private _absoluteTransform;
  13975. private _invertedAbsoluteTransform;
  13976. private _parent;
  13977. private _scalingDeterminant;
  13978. private _worldTransform;
  13979. private _localScaling;
  13980. private _localRotation;
  13981. private _localPosition;
  13982. private _needToDecompose;
  13983. private _needToCompose;
  13984. /** @hidden */
  13985. _linkedTransformNode: Nullable<TransformNode>;
  13986. /** @hidden */
  13987. _waitingTransformNodeId: Nullable<string>;
  13988. /** @hidden */
  13989. get _matrix(): Matrix;
  13990. /** @hidden */
  13991. set _matrix(value: Matrix);
  13992. /**
  13993. * Create a new bone
  13994. * @param name defines the bone name
  13995. * @param skeleton defines the parent skeleton
  13996. * @param parentBone defines the parent (can be null if the bone is the root)
  13997. * @param localMatrix defines the local matrix
  13998. * @param restPose defines the rest pose matrix
  13999. * @param baseMatrix defines the base matrix
  14000. * @param index defines index of the bone in the hiearchy
  14001. */
  14002. constructor(
  14003. /**
  14004. * defines the bone name
  14005. */
  14006. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14007. /**
  14008. * Gets the current object class name.
  14009. * @return the class name
  14010. */
  14011. getClassName(): string;
  14012. /**
  14013. * Gets the parent skeleton
  14014. * @returns a skeleton
  14015. */
  14016. getSkeleton(): Skeleton;
  14017. /**
  14018. * Gets parent bone
  14019. * @returns a bone or null if the bone is the root of the bone hierarchy
  14020. */
  14021. getParent(): Nullable<Bone>;
  14022. /**
  14023. * Returns an array containing the root bones
  14024. * @returns an array containing the root bones
  14025. */
  14026. getChildren(): Array<Bone>;
  14027. /**
  14028. * Gets the node index in matrix array generated for rendering
  14029. * @returns the node index
  14030. */
  14031. getIndex(): number;
  14032. /**
  14033. * Sets the parent bone
  14034. * @param parent defines the parent (can be null if the bone is the root)
  14035. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14036. */
  14037. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14038. /**
  14039. * Gets the local matrix
  14040. * @returns a matrix
  14041. */
  14042. getLocalMatrix(): Matrix;
  14043. /**
  14044. * Gets the base matrix (initial matrix which remains unchanged)
  14045. * @returns a matrix
  14046. */
  14047. getBaseMatrix(): Matrix;
  14048. /**
  14049. * Gets the rest pose matrix
  14050. * @returns a matrix
  14051. */
  14052. getRestPose(): Matrix;
  14053. /**
  14054. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14055. */
  14056. getWorldMatrix(): Matrix;
  14057. /**
  14058. * Sets the local matrix to rest pose matrix
  14059. */
  14060. returnToRest(): void;
  14061. /**
  14062. * Gets the inverse of the absolute transform matrix.
  14063. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14064. * @returns a matrix
  14065. */
  14066. getInvertedAbsoluteTransform(): Matrix;
  14067. /**
  14068. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14069. * @returns a matrix
  14070. */
  14071. getAbsoluteTransform(): Matrix;
  14072. /**
  14073. * Links with the given transform node.
  14074. * The local matrix of this bone is copied from the transform node every frame.
  14075. * @param transformNode defines the transform node to link to
  14076. */
  14077. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14078. /**
  14079. * Gets the node used to drive the bone's transformation
  14080. * @returns a transform node or null
  14081. */
  14082. getTransformNode(): Nullable<TransformNode>;
  14083. /** Gets or sets current position (in local space) */
  14084. get position(): Vector3;
  14085. set position(newPosition: Vector3);
  14086. /** Gets or sets current rotation (in local space) */
  14087. get rotation(): Vector3;
  14088. set rotation(newRotation: Vector3);
  14089. /** Gets or sets current rotation quaternion (in local space) */
  14090. get rotationQuaternion(): Quaternion;
  14091. set rotationQuaternion(newRotation: Quaternion);
  14092. /** Gets or sets current scaling (in local space) */
  14093. get scaling(): Vector3;
  14094. set scaling(newScaling: Vector3);
  14095. /**
  14096. * Gets the animation properties override
  14097. */
  14098. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14099. private _decompose;
  14100. private _compose;
  14101. /**
  14102. * Update the base and local matrices
  14103. * @param matrix defines the new base or local matrix
  14104. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14105. * @param updateLocalMatrix defines if the local matrix should be updated
  14106. */
  14107. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14108. /** @hidden */
  14109. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14110. /**
  14111. * Flag the bone as dirty (Forcing it to update everything)
  14112. */
  14113. markAsDirty(): void;
  14114. /** @hidden */
  14115. _markAsDirtyAndCompose(): void;
  14116. private _markAsDirtyAndDecompose;
  14117. /**
  14118. * Translate the bone in local or world space
  14119. * @param vec The amount to translate the bone
  14120. * @param space The space that the translation is in
  14121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14122. */
  14123. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14124. /**
  14125. * Set the postion of the bone in local or world space
  14126. * @param position The position to set the bone
  14127. * @param space The space that the position is in
  14128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14129. */
  14130. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14131. /**
  14132. * Set the absolute position of the bone (world space)
  14133. * @param position The position to set the bone
  14134. * @param mesh The mesh that this bone is attached to
  14135. */
  14136. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14137. /**
  14138. * Scale the bone on the x, y and z axes (in local space)
  14139. * @param x The amount to scale the bone on the x axis
  14140. * @param y The amount to scale the bone on the y axis
  14141. * @param z The amount to scale the bone on the z axis
  14142. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14143. */
  14144. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14145. /**
  14146. * Set the bone scaling in local space
  14147. * @param scale defines the scaling vector
  14148. */
  14149. setScale(scale: Vector3): void;
  14150. /**
  14151. * Gets the current scaling in local space
  14152. * @returns the current scaling vector
  14153. */
  14154. getScale(): Vector3;
  14155. /**
  14156. * Gets the current scaling in local space and stores it in a target vector
  14157. * @param result defines the target vector
  14158. */
  14159. getScaleToRef(result: Vector3): void;
  14160. /**
  14161. * Set the yaw, pitch, and roll of the bone in local or world space
  14162. * @param yaw The rotation of the bone on the y axis
  14163. * @param pitch The rotation of the bone on the x axis
  14164. * @param roll The rotation of the bone on the z axis
  14165. * @param space The space that the axes of rotation are in
  14166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14167. */
  14168. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14169. /**
  14170. * Add a rotation to the bone on an axis in local or world space
  14171. * @param axis The axis to rotate the bone on
  14172. * @param amount The amount to rotate the bone
  14173. * @param space The space that the axis is in
  14174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14175. */
  14176. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14177. /**
  14178. * Set the rotation of the bone to a particular axis angle in local or world space
  14179. * @param axis The axis to rotate the bone on
  14180. * @param angle The angle that the bone should be rotated to
  14181. * @param space The space that the axis is in
  14182. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14183. */
  14184. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14185. /**
  14186. * Set the euler rotation of the bone in local of world space
  14187. * @param rotation The euler rotation that the bone should be set to
  14188. * @param space The space that the rotation is in
  14189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14190. */
  14191. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14192. /**
  14193. * Set the quaternion rotation of the bone in local of world space
  14194. * @param quat The quaternion rotation that the bone should be set to
  14195. * @param space The space that the rotation is in
  14196. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14197. */
  14198. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14199. /**
  14200. * Set the rotation matrix of the bone in local of world space
  14201. * @param rotMat The rotation matrix that the bone should be set to
  14202. * @param space The space that the rotation is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. */
  14205. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14206. private _rotateWithMatrix;
  14207. private _getNegativeRotationToRef;
  14208. /**
  14209. * Get the position of the bone in local or world space
  14210. * @param space The space that the returned position is in
  14211. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14212. * @returns The position of the bone
  14213. */
  14214. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14215. /**
  14216. * Copy the position of the bone to a vector3 in local or world space
  14217. * @param space The space that the returned position is in
  14218. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14219. * @param result The vector3 to copy the position to
  14220. */
  14221. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14222. /**
  14223. * Get the absolute position of the bone (world space)
  14224. * @param mesh The mesh that this bone is attached to
  14225. * @returns The absolute position of the bone
  14226. */
  14227. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14228. /**
  14229. * Copy the absolute position of the bone (world space) to the result param
  14230. * @param mesh The mesh that this bone is attached to
  14231. * @param result The vector3 to copy the absolute position to
  14232. */
  14233. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14234. /**
  14235. * Compute the absolute transforms of this bone and its children
  14236. */
  14237. computeAbsoluteTransforms(): void;
  14238. /**
  14239. * Get the world direction from an axis that is in the local space of the bone
  14240. * @param localAxis The local direction that is used to compute the world direction
  14241. * @param mesh The mesh that this bone is attached to
  14242. * @returns The world direction
  14243. */
  14244. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14245. /**
  14246. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14247. * @param localAxis The local direction that is used to compute the world direction
  14248. * @param mesh The mesh that this bone is attached to
  14249. * @param result The vector3 that the world direction will be copied to
  14250. */
  14251. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14252. /**
  14253. * Get the euler rotation of the bone in local or world space
  14254. * @param space The space that the rotation should be in
  14255. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14256. * @returns The euler rotation
  14257. */
  14258. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14259. /**
  14260. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14261. * @param space The space that the rotation should be in
  14262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14263. * @param result The vector3 that the rotation should be copied to
  14264. */
  14265. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14266. /**
  14267. * Get the quaternion rotation of the bone in either local or world space
  14268. * @param space The space that the rotation should be in
  14269. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14270. * @returns The quaternion rotation
  14271. */
  14272. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14273. /**
  14274. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14275. * @param space The space that the rotation should be in
  14276. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14277. * @param result The quaternion that the rotation should be copied to
  14278. */
  14279. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14280. /**
  14281. * Get the rotation matrix of the bone in local or world space
  14282. * @param space The space that the rotation should be in
  14283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14284. * @returns The rotation matrix
  14285. */
  14286. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14287. /**
  14288. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14289. * @param space The space that the rotation should be in
  14290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14291. * @param result The quaternion that the rotation should be copied to
  14292. */
  14293. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14294. /**
  14295. * Get the world position of a point that is in the local space of the bone
  14296. * @param position The local position
  14297. * @param mesh The mesh that this bone is attached to
  14298. * @returns The world position
  14299. */
  14300. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14301. /**
  14302. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14303. * @param position The local position
  14304. * @param mesh The mesh that this bone is attached to
  14305. * @param result The vector3 that the world position should be copied to
  14306. */
  14307. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14308. /**
  14309. * Get the local position of a point that is in world space
  14310. * @param position The world position
  14311. * @param mesh The mesh that this bone is attached to
  14312. * @returns The local position
  14313. */
  14314. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14315. /**
  14316. * Get the local position of a point that is in world space and copy it to the result param
  14317. * @param position The world position
  14318. * @param mesh The mesh that this bone is attached to
  14319. * @param result The vector3 that the local position should be copied to
  14320. */
  14321. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14322. }
  14323. }
  14324. declare module BABYLON {
  14325. /**
  14326. * Defines a runtime animation
  14327. */
  14328. export class RuntimeAnimation {
  14329. private _events;
  14330. /**
  14331. * The current frame of the runtime animation
  14332. */
  14333. private _currentFrame;
  14334. /**
  14335. * The animation used by the runtime animation
  14336. */
  14337. private _animation;
  14338. /**
  14339. * The target of the runtime animation
  14340. */
  14341. private _target;
  14342. /**
  14343. * The initiating animatable
  14344. */
  14345. private _host;
  14346. /**
  14347. * The original value of the runtime animation
  14348. */
  14349. private _originalValue;
  14350. /**
  14351. * The original blend value of the runtime animation
  14352. */
  14353. private _originalBlendValue;
  14354. /**
  14355. * The offsets cache of the runtime animation
  14356. */
  14357. private _offsetsCache;
  14358. /**
  14359. * The high limits cache of the runtime animation
  14360. */
  14361. private _highLimitsCache;
  14362. /**
  14363. * Specifies if the runtime animation has been stopped
  14364. */
  14365. private _stopped;
  14366. /**
  14367. * The blending factor of the runtime animation
  14368. */
  14369. private _blendingFactor;
  14370. /**
  14371. * The BabylonJS scene
  14372. */
  14373. private _scene;
  14374. /**
  14375. * The current value of the runtime animation
  14376. */
  14377. private _currentValue;
  14378. /** @hidden */
  14379. _animationState: _IAnimationState;
  14380. /**
  14381. * The active target of the runtime animation
  14382. */
  14383. private _activeTargets;
  14384. private _currentActiveTarget;
  14385. private _directTarget;
  14386. /**
  14387. * The target path of the runtime animation
  14388. */
  14389. private _targetPath;
  14390. /**
  14391. * The weight of the runtime animation
  14392. */
  14393. private _weight;
  14394. /**
  14395. * The ratio offset of the runtime animation
  14396. */
  14397. private _ratioOffset;
  14398. /**
  14399. * The previous delay of the runtime animation
  14400. */
  14401. private _previousDelay;
  14402. /**
  14403. * The previous ratio of the runtime animation
  14404. */
  14405. private _previousRatio;
  14406. private _enableBlending;
  14407. private _keys;
  14408. private _minFrame;
  14409. private _maxFrame;
  14410. private _minValue;
  14411. private _maxValue;
  14412. private _targetIsArray;
  14413. /**
  14414. * Gets the current frame of the runtime animation
  14415. */
  14416. get currentFrame(): number;
  14417. /**
  14418. * Gets the weight of the runtime animation
  14419. */
  14420. get weight(): number;
  14421. /**
  14422. * Gets the current value of the runtime animation
  14423. */
  14424. get currentValue(): any;
  14425. /**
  14426. * Gets the target path of the runtime animation
  14427. */
  14428. get targetPath(): string;
  14429. /**
  14430. * Gets the actual target of the runtime animation
  14431. */
  14432. get target(): any;
  14433. /** @hidden */
  14434. _onLoop: () => void;
  14435. /**
  14436. * Create a new RuntimeAnimation object
  14437. * @param target defines the target of the animation
  14438. * @param animation defines the source animation object
  14439. * @param scene defines the hosting scene
  14440. * @param host defines the initiating Animatable
  14441. */
  14442. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14443. private _preparePath;
  14444. /**
  14445. * Gets the animation from the runtime animation
  14446. */
  14447. get animation(): Animation;
  14448. /**
  14449. * Resets the runtime animation to the beginning
  14450. * @param restoreOriginal defines whether to restore the target property to the original value
  14451. */
  14452. reset(restoreOriginal?: boolean): void;
  14453. /**
  14454. * Specifies if the runtime animation is stopped
  14455. * @returns Boolean specifying if the runtime animation is stopped
  14456. */
  14457. isStopped(): boolean;
  14458. /**
  14459. * Disposes of the runtime animation
  14460. */
  14461. dispose(): void;
  14462. /**
  14463. * Apply the interpolated value to the target
  14464. * @param currentValue defines the value computed by the animation
  14465. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14466. */
  14467. setValue(currentValue: any, weight: number): void;
  14468. private _getOriginalValues;
  14469. private _setValue;
  14470. /**
  14471. * Gets the loop pmode of the runtime animation
  14472. * @returns Loop Mode
  14473. */
  14474. private _getCorrectLoopMode;
  14475. /**
  14476. * Move the current animation to a given frame
  14477. * @param frame defines the frame to move to
  14478. */
  14479. goToFrame(frame: number): void;
  14480. /**
  14481. * @hidden Internal use only
  14482. */
  14483. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14484. /**
  14485. * Execute the current animation
  14486. * @param delay defines the delay to add to the current frame
  14487. * @param from defines the lower bound of the animation range
  14488. * @param to defines the upper bound of the animation range
  14489. * @param loop defines if the current animation must loop
  14490. * @param speedRatio defines the current speed ratio
  14491. * @param weight defines the weight of the animation (default is -1 so no weight)
  14492. * @param onLoop optional callback called when animation loops
  14493. * @returns a boolean indicating if the animation is running
  14494. */
  14495. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14496. }
  14497. }
  14498. declare module BABYLON {
  14499. /**
  14500. * Class used to store an actual running animation
  14501. */
  14502. export class Animatable {
  14503. /** defines the target object */
  14504. target: any;
  14505. /** defines the starting frame number (default is 0) */
  14506. fromFrame: number;
  14507. /** defines the ending frame number (default is 100) */
  14508. toFrame: number;
  14509. /** defines if the animation must loop (default is false) */
  14510. loopAnimation: boolean;
  14511. /** defines a callback to call when animation ends if it is not looping */
  14512. onAnimationEnd?: (() => void) | null | undefined;
  14513. /** defines a callback to call when animation loops */
  14514. onAnimationLoop?: (() => void) | null | undefined;
  14515. private _localDelayOffset;
  14516. private _pausedDelay;
  14517. private _runtimeAnimations;
  14518. private _paused;
  14519. private _scene;
  14520. private _speedRatio;
  14521. private _weight;
  14522. private _syncRoot;
  14523. /**
  14524. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14525. * This will only apply for non looping animation (default is true)
  14526. */
  14527. disposeOnEnd: boolean;
  14528. /**
  14529. * Gets a boolean indicating if the animation has started
  14530. */
  14531. animationStarted: boolean;
  14532. /**
  14533. * Observer raised when the animation ends
  14534. */
  14535. onAnimationEndObservable: Observable<Animatable>;
  14536. /**
  14537. * Observer raised when the animation loops
  14538. */
  14539. onAnimationLoopObservable: Observable<Animatable>;
  14540. /**
  14541. * Gets the root Animatable used to synchronize and normalize animations
  14542. */
  14543. get syncRoot(): Nullable<Animatable>;
  14544. /**
  14545. * Gets the current frame of the first RuntimeAnimation
  14546. * Used to synchronize Animatables
  14547. */
  14548. get masterFrame(): number;
  14549. /**
  14550. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14551. */
  14552. get weight(): number;
  14553. set weight(value: number);
  14554. /**
  14555. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14556. */
  14557. get speedRatio(): number;
  14558. set speedRatio(value: number);
  14559. /**
  14560. * Creates a new Animatable
  14561. * @param scene defines the hosting scene
  14562. * @param target defines the target object
  14563. * @param fromFrame defines the starting frame number (default is 0)
  14564. * @param toFrame defines the ending frame number (default is 100)
  14565. * @param loopAnimation defines if the animation must loop (default is false)
  14566. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14567. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14568. * @param animations defines a group of animation to add to the new Animatable
  14569. * @param onAnimationLoop defines a callback to call when animation loops
  14570. */
  14571. constructor(scene: Scene,
  14572. /** defines the target object */
  14573. target: any,
  14574. /** defines the starting frame number (default is 0) */
  14575. fromFrame?: number,
  14576. /** defines the ending frame number (default is 100) */
  14577. toFrame?: number,
  14578. /** defines if the animation must loop (default is false) */
  14579. loopAnimation?: boolean, speedRatio?: number,
  14580. /** defines a callback to call when animation ends if it is not looping */
  14581. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14582. /** defines a callback to call when animation loops */
  14583. onAnimationLoop?: (() => void) | null | undefined);
  14584. /**
  14585. * Synchronize and normalize current Animatable with a source Animatable
  14586. * This is useful when using animation weights and when animations are not of the same length
  14587. * @param root defines the root Animatable to synchronize with
  14588. * @returns the current Animatable
  14589. */
  14590. syncWith(root: Animatable): Animatable;
  14591. /**
  14592. * Gets the list of runtime animations
  14593. * @returns an array of RuntimeAnimation
  14594. */
  14595. getAnimations(): RuntimeAnimation[];
  14596. /**
  14597. * Adds more animations to the current animatable
  14598. * @param target defines the target of the animations
  14599. * @param animations defines the new animations to add
  14600. */
  14601. appendAnimations(target: any, animations: Animation[]): void;
  14602. /**
  14603. * Gets the source animation for a specific property
  14604. * @param property defines the propertyu to look for
  14605. * @returns null or the source animation for the given property
  14606. */
  14607. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14608. /**
  14609. * Gets the runtime animation for a specific property
  14610. * @param property defines the propertyu to look for
  14611. * @returns null or the runtime animation for the given property
  14612. */
  14613. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14614. /**
  14615. * Resets the animatable to its original state
  14616. */
  14617. reset(): void;
  14618. /**
  14619. * Allows the animatable to blend with current running animations
  14620. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14621. * @param blendingSpeed defines the blending speed to use
  14622. */
  14623. enableBlending(blendingSpeed: number): void;
  14624. /**
  14625. * Disable animation blending
  14626. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14627. */
  14628. disableBlending(): void;
  14629. /**
  14630. * Jump directly to a given frame
  14631. * @param frame defines the frame to jump to
  14632. */
  14633. goToFrame(frame: number): void;
  14634. /**
  14635. * Pause the animation
  14636. */
  14637. pause(): void;
  14638. /**
  14639. * Restart the animation
  14640. */
  14641. restart(): void;
  14642. private _raiseOnAnimationEnd;
  14643. /**
  14644. * Stop and delete the current animation
  14645. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14646. * @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)
  14647. */
  14648. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14649. /**
  14650. * Wait asynchronously for the animation to end
  14651. * @returns a promise which will be fullfilled when the animation ends
  14652. */
  14653. waitAsync(): Promise<Animatable>;
  14654. /** @hidden */
  14655. _animate(delay: number): boolean;
  14656. }
  14657. interface Scene {
  14658. /** @hidden */
  14659. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14660. /** @hidden */
  14661. _processLateAnimationBindingsForMatrices(holder: {
  14662. totalWeight: number;
  14663. animations: RuntimeAnimation[];
  14664. originalValue: Matrix;
  14665. }): any;
  14666. /** @hidden */
  14667. _processLateAnimationBindingsForQuaternions(holder: {
  14668. totalWeight: number;
  14669. animations: RuntimeAnimation[];
  14670. originalValue: Quaternion;
  14671. }, refQuaternion: Quaternion): Quaternion;
  14672. /** @hidden */
  14673. _processLateAnimationBindings(): void;
  14674. /**
  14675. * Will start the animation sequence of a given target
  14676. * @param target defines the target
  14677. * @param from defines from which frame should animation start
  14678. * @param to defines until which frame should animation run.
  14679. * @param weight defines the weight to apply to the animation (1.0 by default)
  14680. * @param loop defines if the animation loops
  14681. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14682. * @param onAnimationEnd defines the function to be executed when the animation ends
  14683. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14684. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14685. * @param onAnimationLoop defines the callback to call when an animation loops
  14686. * @returns the animatable object created for this animation
  14687. */
  14688. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14689. /**
  14690. * Will start the animation sequence of a given target
  14691. * @param target defines the target
  14692. * @param from defines from which frame should animation start
  14693. * @param to defines until which frame should animation run.
  14694. * @param loop defines if the animation loops
  14695. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14696. * @param onAnimationEnd defines the function to be executed when the animation ends
  14697. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14698. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14699. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14700. * @param onAnimationLoop defines the callback to call when an animation loops
  14701. * @returns the animatable object created for this animation
  14702. */
  14703. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14704. /**
  14705. * Will start the animation sequence of a given target and its hierarchy
  14706. * @param target defines the target
  14707. * @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.
  14708. * @param from defines from which frame should animation start
  14709. * @param to defines until which frame should animation run.
  14710. * @param loop defines if the animation loops
  14711. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14712. * @param onAnimationEnd defines the function to be executed when the animation ends
  14713. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14714. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14715. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14716. * @param onAnimationLoop defines the callback to call when an animation loops
  14717. * @returns the list of created animatables
  14718. */
  14719. 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[];
  14720. /**
  14721. * Begin a new animation on a given node
  14722. * @param target defines the target where the animation will take place
  14723. * @param animations defines the list of animations to start
  14724. * @param from defines the initial value
  14725. * @param to defines the final value
  14726. * @param loop defines if you want animation to loop (off by default)
  14727. * @param speedRatio defines the speed ratio to apply to all animations
  14728. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14729. * @param onAnimationLoop defines the callback to call when an animation loops
  14730. * @returns the list of created animatables
  14731. */
  14732. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14733. /**
  14734. * Begin a new animation on a given node and its hierarchy
  14735. * @param target defines the root node where the animation will take place
  14736. * @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.
  14737. * @param animations defines the list of animations to start
  14738. * @param from defines the initial value
  14739. * @param to defines the final value
  14740. * @param loop defines if you want animation to loop (off by default)
  14741. * @param speedRatio defines the speed ratio to apply to all animations
  14742. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14743. * @param onAnimationLoop defines the callback to call when an animation loops
  14744. * @returns the list of animatables created for all nodes
  14745. */
  14746. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14747. /**
  14748. * Gets the animatable associated with a specific target
  14749. * @param target defines the target of the animatable
  14750. * @returns the required animatable if found
  14751. */
  14752. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14753. /**
  14754. * Gets all animatables associated with a given target
  14755. * @param target defines the target to look animatables for
  14756. * @returns an array of Animatables
  14757. */
  14758. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14759. /**
  14760. * Stops and removes all animations that have been applied to the scene
  14761. */
  14762. stopAllAnimations(): void;
  14763. /**
  14764. * Gets the current delta time used by animation engine
  14765. */
  14766. deltaTime: number;
  14767. }
  14768. interface Bone {
  14769. /**
  14770. * Copy an animation range from another bone
  14771. * @param source defines the source bone
  14772. * @param rangeName defines the range name to copy
  14773. * @param frameOffset defines the frame offset
  14774. * @param rescaleAsRequired defines if rescaling must be applied if required
  14775. * @param skelDimensionsRatio defines the scaling ratio
  14776. * @returns true if operation was successful
  14777. */
  14778. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14779. }
  14780. }
  14781. declare module BABYLON {
  14782. /**
  14783. * Class used to handle skinning animations
  14784. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14785. */
  14786. export class Skeleton implements IAnimatable {
  14787. /** defines the skeleton name */
  14788. name: string;
  14789. /** defines the skeleton Id */
  14790. id: string;
  14791. /**
  14792. * Defines the list of child bones
  14793. */
  14794. bones: Bone[];
  14795. /**
  14796. * Defines an estimate of the dimension of the skeleton at rest
  14797. */
  14798. dimensionsAtRest: Vector3;
  14799. /**
  14800. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14801. */
  14802. needInitialSkinMatrix: boolean;
  14803. /**
  14804. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14805. */
  14806. overrideMesh: Nullable<AbstractMesh>;
  14807. /**
  14808. * Gets the list of animations attached to this skeleton
  14809. */
  14810. animations: Array<Animation>;
  14811. private _scene;
  14812. private _isDirty;
  14813. private _transformMatrices;
  14814. private _transformMatrixTexture;
  14815. private _meshesWithPoseMatrix;
  14816. private _animatables;
  14817. private _identity;
  14818. private _synchronizedWithMesh;
  14819. private _ranges;
  14820. private _lastAbsoluteTransformsUpdateId;
  14821. private _canUseTextureForBones;
  14822. private _uniqueId;
  14823. /** @hidden */
  14824. _numBonesWithLinkedTransformNode: number;
  14825. /** @hidden */
  14826. _hasWaitingData: Nullable<boolean>;
  14827. /**
  14828. * Specifies if the skeleton should be serialized
  14829. */
  14830. doNotSerialize: boolean;
  14831. private _useTextureToStoreBoneMatrices;
  14832. /**
  14833. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14834. * Please note that this option is not available if the hardware does not support it
  14835. */
  14836. get useTextureToStoreBoneMatrices(): boolean;
  14837. set useTextureToStoreBoneMatrices(value: boolean);
  14838. private _animationPropertiesOverride;
  14839. /**
  14840. * Gets or sets the animation properties override
  14841. */
  14842. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14843. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14844. /**
  14845. * List of inspectable custom properties (used by the Inspector)
  14846. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14847. */
  14848. inspectableCustomProperties: IInspectable[];
  14849. /**
  14850. * An observable triggered before computing the skeleton's matrices
  14851. */
  14852. onBeforeComputeObservable: Observable<Skeleton>;
  14853. /**
  14854. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14855. */
  14856. get isUsingTextureForMatrices(): boolean;
  14857. /**
  14858. * Gets the unique ID of this skeleton
  14859. */
  14860. get uniqueId(): number;
  14861. /**
  14862. * Creates a new skeleton
  14863. * @param name defines the skeleton name
  14864. * @param id defines the skeleton Id
  14865. * @param scene defines the hosting scene
  14866. */
  14867. constructor(
  14868. /** defines the skeleton name */
  14869. name: string,
  14870. /** defines the skeleton Id */
  14871. id: string, scene: Scene);
  14872. /**
  14873. * Gets the current object class name.
  14874. * @return the class name
  14875. */
  14876. getClassName(): string;
  14877. /**
  14878. * Returns an array containing the root bones
  14879. * @returns an array containing the root bones
  14880. */
  14881. getChildren(): Array<Bone>;
  14882. /**
  14883. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14884. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14885. * @returns a Float32Array containing matrices data
  14886. */
  14887. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14888. /**
  14889. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14890. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14891. * @returns a raw texture containing the data
  14892. */
  14893. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14894. /**
  14895. * Gets the current hosting scene
  14896. * @returns a scene object
  14897. */
  14898. getScene(): Scene;
  14899. /**
  14900. * Gets a string representing the current skeleton data
  14901. * @param fullDetails defines a boolean indicating if we want a verbose version
  14902. * @returns a string representing the current skeleton data
  14903. */
  14904. toString(fullDetails?: boolean): string;
  14905. /**
  14906. * Get bone's index searching by name
  14907. * @param name defines bone's name to search for
  14908. * @return the indice of the bone. Returns -1 if not found
  14909. */
  14910. getBoneIndexByName(name: string): number;
  14911. /**
  14912. * Creater a new animation range
  14913. * @param name defines the name of the range
  14914. * @param from defines the start key
  14915. * @param to defines the end key
  14916. */
  14917. createAnimationRange(name: string, from: number, to: number): void;
  14918. /**
  14919. * Delete a specific animation range
  14920. * @param name defines the name of the range
  14921. * @param deleteFrames defines if frames must be removed as well
  14922. */
  14923. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14924. /**
  14925. * Gets a specific animation range
  14926. * @param name defines the name of the range to look for
  14927. * @returns the requested animation range or null if not found
  14928. */
  14929. getAnimationRange(name: string): Nullable<AnimationRange>;
  14930. /**
  14931. * Gets the list of all animation ranges defined on this skeleton
  14932. * @returns an array
  14933. */
  14934. getAnimationRanges(): Nullable<AnimationRange>[];
  14935. /**
  14936. * Copy animation range from a source skeleton.
  14937. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14938. * @param source defines the source skeleton
  14939. * @param name defines the name of the range to copy
  14940. * @param rescaleAsRequired defines if rescaling must be applied if required
  14941. * @returns true if operation was successful
  14942. */
  14943. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14944. /**
  14945. * Forces the skeleton to go to rest pose
  14946. */
  14947. returnToRest(): void;
  14948. private _getHighestAnimationFrame;
  14949. /**
  14950. * Begin a specific animation range
  14951. * @param name defines the name of the range to start
  14952. * @param loop defines if looping must be turned on (false by default)
  14953. * @param speedRatio defines the speed ratio to apply (1 by default)
  14954. * @param onAnimationEnd defines a callback which will be called when animation will end
  14955. * @returns a new animatable
  14956. */
  14957. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14958. /** @hidden */
  14959. _markAsDirty(): void;
  14960. /** @hidden */
  14961. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14962. /** @hidden */
  14963. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14964. private _computeTransformMatrices;
  14965. /**
  14966. * Build all resources required to render a skeleton
  14967. */
  14968. prepare(): void;
  14969. /**
  14970. * Gets the list of animatables currently running for this skeleton
  14971. * @returns an array of animatables
  14972. */
  14973. getAnimatables(): IAnimatable[];
  14974. /**
  14975. * Clone the current skeleton
  14976. * @param name defines the name of the new skeleton
  14977. * @param id defines the id of the new skeleton
  14978. * @returns the new skeleton
  14979. */
  14980. clone(name: string, id?: string): Skeleton;
  14981. /**
  14982. * Enable animation blending for this skeleton
  14983. * @param blendingSpeed defines the blending speed to apply
  14984. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14985. */
  14986. enableBlending(blendingSpeed?: number): void;
  14987. /**
  14988. * Releases all resources associated with the current skeleton
  14989. */
  14990. dispose(): void;
  14991. /**
  14992. * Serialize the skeleton in a JSON object
  14993. * @returns a JSON object
  14994. */
  14995. serialize(): any;
  14996. /**
  14997. * Creates a new skeleton from serialized data
  14998. * @param parsedSkeleton defines the serialized data
  14999. * @param scene defines the hosting scene
  15000. * @returns a new skeleton
  15001. */
  15002. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15003. /**
  15004. * Compute all node absolute transforms
  15005. * @param forceUpdate defines if computation must be done even if cache is up to date
  15006. */
  15007. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15008. /**
  15009. * Gets the root pose matrix
  15010. * @returns a matrix
  15011. */
  15012. getPoseMatrix(): Nullable<Matrix>;
  15013. /**
  15014. * Sorts bones per internal index
  15015. */
  15016. sortBones(): void;
  15017. private _sortBones;
  15018. }
  15019. }
  15020. declare module BABYLON {
  15021. /**
  15022. * Creates an instance based on a source mesh.
  15023. */
  15024. export class InstancedMesh extends AbstractMesh {
  15025. private _sourceMesh;
  15026. private _currentLOD;
  15027. /** @hidden */
  15028. _indexInSourceMeshInstanceArray: number;
  15029. constructor(name: string, source: Mesh);
  15030. /**
  15031. * Returns the string "InstancedMesh".
  15032. */
  15033. getClassName(): string;
  15034. /** Gets the list of lights affecting that mesh */
  15035. get lightSources(): Light[];
  15036. _resyncLightSources(): void;
  15037. _resyncLightSource(light: Light): void;
  15038. _removeLightSource(light: Light, dispose: boolean): void;
  15039. /**
  15040. * If the source mesh receives shadows
  15041. */
  15042. get receiveShadows(): boolean;
  15043. /**
  15044. * The material of the source mesh
  15045. */
  15046. get material(): Nullable<Material>;
  15047. /**
  15048. * Visibility of the source mesh
  15049. */
  15050. get visibility(): number;
  15051. /**
  15052. * Skeleton of the source mesh
  15053. */
  15054. get skeleton(): Nullable<Skeleton>;
  15055. /**
  15056. * Rendering ground id of the source mesh
  15057. */
  15058. get renderingGroupId(): number;
  15059. set renderingGroupId(value: number);
  15060. /**
  15061. * Returns the total number of vertices (integer).
  15062. */
  15063. getTotalVertices(): number;
  15064. /**
  15065. * Returns a positive integer : the total number of indices in this mesh geometry.
  15066. * @returns the numner of indices or zero if the mesh has no geometry.
  15067. */
  15068. getTotalIndices(): number;
  15069. /**
  15070. * The source mesh of the instance
  15071. */
  15072. get sourceMesh(): Mesh;
  15073. /**
  15074. * Is this node ready to be used/rendered
  15075. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15076. * @return {boolean} is it ready
  15077. */
  15078. isReady(completeCheck?: boolean): boolean;
  15079. /**
  15080. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15081. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15082. * @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.
  15083. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15084. */
  15085. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15086. /**
  15087. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15088. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15089. * The `data` are either a numeric array either a Float32Array.
  15090. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15091. * 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).
  15092. * Note that a new underlying VertexBuffer object is created each call.
  15093. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15094. *
  15095. * Possible `kind` values :
  15096. * - VertexBuffer.PositionKind
  15097. * - VertexBuffer.UVKind
  15098. * - VertexBuffer.UV2Kind
  15099. * - VertexBuffer.UV3Kind
  15100. * - VertexBuffer.UV4Kind
  15101. * - VertexBuffer.UV5Kind
  15102. * - VertexBuffer.UV6Kind
  15103. * - VertexBuffer.ColorKind
  15104. * - VertexBuffer.MatricesIndicesKind
  15105. * - VertexBuffer.MatricesIndicesExtraKind
  15106. * - VertexBuffer.MatricesWeightsKind
  15107. * - VertexBuffer.MatricesWeightsExtraKind
  15108. *
  15109. * Returns the Mesh.
  15110. */
  15111. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15112. /**
  15113. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15114. * If the mesh has no geometry, it is simply returned as it is.
  15115. * The `data` are either a numeric array either a Float32Array.
  15116. * No new underlying VertexBuffer object is created.
  15117. * 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.
  15118. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15119. *
  15120. * Possible `kind` values :
  15121. * - VertexBuffer.PositionKind
  15122. * - VertexBuffer.UVKind
  15123. * - VertexBuffer.UV2Kind
  15124. * - VertexBuffer.UV3Kind
  15125. * - VertexBuffer.UV4Kind
  15126. * - VertexBuffer.UV5Kind
  15127. * - VertexBuffer.UV6Kind
  15128. * - VertexBuffer.ColorKind
  15129. * - VertexBuffer.MatricesIndicesKind
  15130. * - VertexBuffer.MatricesIndicesExtraKind
  15131. * - VertexBuffer.MatricesWeightsKind
  15132. * - VertexBuffer.MatricesWeightsExtraKind
  15133. *
  15134. * Returns the Mesh.
  15135. */
  15136. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15137. /**
  15138. * Sets the mesh indices.
  15139. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15140. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15141. * This method creates a new index buffer each call.
  15142. * Returns the Mesh.
  15143. */
  15144. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15145. /**
  15146. * Boolean : True if the mesh owns the requested kind of data.
  15147. */
  15148. isVerticesDataPresent(kind: string): boolean;
  15149. /**
  15150. * Returns an array of indices (IndicesArray).
  15151. */
  15152. getIndices(): Nullable<IndicesArray>;
  15153. get _positions(): Nullable<Vector3[]>;
  15154. /**
  15155. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15156. * This means the mesh underlying bounding box and sphere are recomputed.
  15157. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15158. * @returns the current mesh
  15159. */
  15160. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15161. /** @hidden */
  15162. _preActivate(): InstancedMesh;
  15163. /** @hidden */
  15164. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15165. /** @hidden */
  15166. _postActivate(): void;
  15167. getWorldMatrix(): Matrix;
  15168. get isAnInstance(): boolean;
  15169. /**
  15170. * Returns the current associated LOD AbstractMesh.
  15171. */
  15172. getLOD(camera: Camera): AbstractMesh;
  15173. /** @hidden */
  15174. _syncSubMeshes(): InstancedMesh;
  15175. /** @hidden */
  15176. _generatePointsArray(): boolean;
  15177. /**
  15178. * Creates a new InstancedMesh from the current mesh.
  15179. * - name (string) : the cloned mesh name
  15180. * - newParent (optional Node) : the optional Node to parent the clone to.
  15181. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15182. *
  15183. * Returns the clone.
  15184. */
  15185. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15186. /**
  15187. * Disposes the InstancedMesh.
  15188. * Returns nothing.
  15189. */
  15190. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15191. }
  15192. interface Mesh {
  15193. /**
  15194. * Register a custom buffer that will be instanced
  15195. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15196. * @param kind defines the buffer kind
  15197. * @param stride defines the stride in floats
  15198. */
  15199. registerInstancedBuffer(kind: string, stride: number): void;
  15200. /** @hidden */
  15201. _userInstancedBuffersStorage: {
  15202. data: {
  15203. [key: string]: Float32Array;
  15204. };
  15205. sizes: {
  15206. [key: string]: number;
  15207. };
  15208. vertexBuffers: {
  15209. [key: string]: Nullable<VertexBuffer>;
  15210. };
  15211. strides: {
  15212. [key: string]: number;
  15213. };
  15214. };
  15215. }
  15216. interface AbstractMesh {
  15217. /**
  15218. * Object used to store instanced buffers defined by user
  15219. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15220. */
  15221. instancedBuffers: {
  15222. [key: string]: any;
  15223. };
  15224. }
  15225. }
  15226. declare module BABYLON {
  15227. /**
  15228. * Defines the options associated with the creation of a shader material.
  15229. */
  15230. export interface IShaderMaterialOptions {
  15231. /**
  15232. * Does the material work in alpha blend mode
  15233. */
  15234. needAlphaBlending: boolean;
  15235. /**
  15236. * Does the material work in alpha test mode
  15237. */
  15238. needAlphaTesting: boolean;
  15239. /**
  15240. * The list of attribute names used in the shader
  15241. */
  15242. attributes: string[];
  15243. /**
  15244. * The list of unifrom names used in the shader
  15245. */
  15246. uniforms: string[];
  15247. /**
  15248. * The list of UBO names used in the shader
  15249. */
  15250. uniformBuffers: string[];
  15251. /**
  15252. * The list of sampler names used in the shader
  15253. */
  15254. samplers: string[];
  15255. /**
  15256. * The list of defines used in the shader
  15257. */
  15258. defines: string[];
  15259. }
  15260. /**
  15261. * 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.
  15262. *
  15263. * This returned material effects how the mesh will look based on the code in the shaders.
  15264. *
  15265. * @see http://doc.babylonjs.com/how_to/shader_material
  15266. */
  15267. export class ShaderMaterial extends Material {
  15268. private _shaderPath;
  15269. private _options;
  15270. private _textures;
  15271. private _textureArrays;
  15272. private _floats;
  15273. private _ints;
  15274. private _floatsArrays;
  15275. private _colors3;
  15276. private _colors3Arrays;
  15277. private _colors4;
  15278. private _colors4Arrays;
  15279. private _vectors2;
  15280. private _vectors3;
  15281. private _vectors4;
  15282. private _matrices;
  15283. private _matrixArrays;
  15284. private _matrices3x3;
  15285. private _matrices2x2;
  15286. private _vectors2Arrays;
  15287. private _vectors3Arrays;
  15288. private _vectors4Arrays;
  15289. private _cachedWorldViewMatrix;
  15290. private _cachedWorldViewProjectionMatrix;
  15291. private _renderId;
  15292. private _multiview;
  15293. /**
  15294. * Instantiate a new shader material.
  15295. * 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.
  15296. * This returned material effects how the mesh will look based on the code in the shaders.
  15297. * @see http://doc.babylonjs.com/how_to/shader_material
  15298. * @param name Define the name of the material in the scene
  15299. * @param scene Define the scene the material belongs to
  15300. * @param shaderPath Defines the route to the shader code in one of three ways:
  15301. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15302. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15303. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15304. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15305. * @param options Define the options used to create the shader
  15306. */
  15307. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15308. /**
  15309. * Gets the shader path used to define the shader code
  15310. * It can be modified to trigger a new compilation
  15311. */
  15312. get shaderPath(): any;
  15313. /**
  15314. * Sets the shader path used to define the shader code
  15315. * It can be modified to trigger a new compilation
  15316. */
  15317. set shaderPath(shaderPath: any);
  15318. /**
  15319. * Gets the options used to compile the shader.
  15320. * They can be modified to trigger a new compilation
  15321. */
  15322. get options(): IShaderMaterialOptions;
  15323. /**
  15324. * Gets the current class name of the material e.g. "ShaderMaterial"
  15325. * Mainly use in serialization.
  15326. * @returns the class name
  15327. */
  15328. getClassName(): string;
  15329. /**
  15330. * Specifies if the material will require alpha blending
  15331. * @returns a boolean specifying if alpha blending is needed
  15332. */
  15333. needAlphaBlending(): boolean;
  15334. /**
  15335. * Specifies if this material should be rendered in alpha test mode
  15336. * @returns a boolean specifying if an alpha test is needed.
  15337. */
  15338. needAlphaTesting(): boolean;
  15339. private _checkUniform;
  15340. /**
  15341. * Set a texture in the shader.
  15342. * @param name Define the name of the uniform samplers as defined in the shader
  15343. * @param texture Define the texture to bind to this sampler
  15344. * @return the material itself allowing "fluent" like uniform updates
  15345. */
  15346. setTexture(name: string, texture: Texture): ShaderMaterial;
  15347. /**
  15348. * Set a texture array in the shader.
  15349. * @param name Define the name of the uniform sampler array as defined in the shader
  15350. * @param textures Define the list of textures to bind to this sampler
  15351. * @return the material itself allowing "fluent" like uniform updates
  15352. */
  15353. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15354. /**
  15355. * Set a float in the shader.
  15356. * @param name Define the name of the uniform as defined in the shader
  15357. * @param value Define the value to give to the uniform
  15358. * @return the material itself allowing "fluent" like uniform updates
  15359. */
  15360. setFloat(name: string, value: number): ShaderMaterial;
  15361. /**
  15362. * Set a int in the shader.
  15363. * @param name Define the name of the uniform as defined in the shader
  15364. * @param value Define the value to give to the uniform
  15365. * @return the material itself allowing "fluent" like uniform updates
  15366. */
  15367. setInt(name: string, value: number): ShaderMaterial;
  15368. /**
  15369. * Set an array of floats in the shader.
  15370. * @param name Define the name of the uniform as defined in the shader
  15371. * @param value Define the value to give to the uniform
  15372. * @return the material itself allowing "fluent" like uniform updates
  15373. */
  15374. setFloats(name: string, value: number[]): ShaderMaterial;
  15375. /**
  15376. * Set a vec3 in the shader from a Color3.
  15377. * @param name Define the name of the uniform as defined in the shader
  15378. * @param value Define the value to give to the uniform
  15379. * @return the material itself allowing "fluent" like uniform updates
  15380. */
  15381. setColor3(name: string, value: Color3): ShaderMaterial;
  15382. /**
  15383. * Set a vec3 array in the shader from a Color3 array.
  15384. * @param name Define the name of the uniform as defined in the shader
  15385. * @param value Define the value to give to the uniform
  15386. * @return the material itself allowing "fluent" like uniform updates
  15387. */
  15388. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15389. /**
  15390. * Set a vec4 in the shader from a Color4.
  15391. * @param name Define the name of the uniform as defined in the shader
  15392. * @param value Define the value to give to the uniform
  15393. * @return the material itself allowing "fluent" like uniform updates
  15394. */
  15395. setColor4(name: string, value: Color4): ShaderMaterial;
  15396. /**
  15397. * Set a vec4 array in the shader from a Color4 array.
  15398. * @param name Define the name of the uniform as defined in the shader
  15399. * @param value Define the value to give to the uniform
  15400. * @return the material itself allowing "fluent" like uniform updates
  15401. */
  15402. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15403. /**
  15404. * Set a vec2 in the shader from a Vector2.
  15405. * @param name Define the name of the uniform as defined in the shader
  15406. * @param value Define the value to give to the uniform
  15407. * @return the material itself allowing "fluent" like uniform updates
  15408. */
  15409. setVector2(name: string, value: Vector2): ShaderMaterial;
  15410. /**
  15411. * Set a vec3 in the shader from a Vector3.
  15412. * @param name Define the name of the uniform as defined in the shader
  15413. * @param value Define the value to give to the uniform
  15414. * @return the material itself allowing "fluent" like uniform updates
  15415. */
  15416. setVector3(name: string, value: Vector3): ShaderMaterial;
  15417. /**
  15418. * Set a vec4 in the shader from a Vector4.
  15419. * @param name Define the name of the uniform as defined in the shader
  15420. * @param value Define the value to give to the uniform
  15421. * @return the material itself allowing "fluent" like uniform updates
  15422. */
  15423. setVector4(name: string, value: Vector4): ShaderMaterial;
  15424. /**
  15425. * Set a mat4 in the shader from a Matrix.
  15426. * @param name Define the name of the uniform as defined in the shader
  15427. * @param value Define the value to give to the uniform
  15428. * @return the material itself allowing "fluent" like uniform updates
  15429. */
  15430. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15431. /**
  15432. * Set a float32Array in the shader from a matrix array.
  15433. * @param name Define the name of the uniform as defined in the shader
  15434. * @param value Define the value to give to the uniform
  15435. * @return the material itself allowing "fluent" like uniform updates
  15436. */
  15437. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15438. /**
  15439. * Set a mat3 in the shader from a Float32Array.
  15440. * @param name Define the name of the uniform as defined in the shader
  15441. * @param value Define the value to give to the uniform
  15442. * @return the material itself allowing "fluent" like uniform updates
  15443. */
  15444. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15445. /**
  15446. * Set a mat2 in the shader from a Float32Array.
  15447. * @param name Define the name of the uniform as defined in the shader
  15448. * @param value Define the value to give to the uniform
  15449. * @return the material itself allowing "fluent" like uniform updates
  15450. */
  15451. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15452. /**
  15453. * Set a vec2 array in the shader from a number array.
  15454. * @param name Define the name of the uniform as defined in the shader
  15455. * @param value Define the value to give to the uniform
  15456. * @return the material itself allowing "fluent" like uniform updates
  15457. */
  15458. setArray2(name: string, value: number[]): ShaderMaterial;
  15459. /**
  15460. * Set a vec3 array in the shader from a number array.
  15461. * @param name Define the name of the uniform as defined in the shader
  15462. * @param value Define the value to give to the uniform
  15463. * @return the material itself allowing "fluent" like uniform updates
  15464. */
  15465. setArray3(name: string, value: number[]): ShaderMaterial;
  15466. /**
  15467. * Set a vec4 array in the shader from a number array.
  15468. * @param name Define the name of the uniform as defined in the shader
  15469. * @param value Define the value to give to the uniform
  15470. * @return the material itself allowing "fluent" like uniform updates
  15471. */
  15472. setArray4(name: string, value: number[]): ShaderMaterial;
  15473. private _checkCache;
  15474. /**
  15475. * Specifies that the submesh is ready to be used
  15476. * @param mesh defines the mesh to check
  15477. * @param subMesh defines which submesh to check
  15478. * @param useInstances specifies that instances should be used
  15479. * @returns a boolean indicating that the submesh is ready or not
  15480. */
  15481. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15482. /**
  15483. * Checks if the material is ready to render the requested mesh
  15484. * @param mesh Define the mesh to render
  15485. * @param useInstances Define whether or not the material is used with instances
  15486. * @returns true if ready, otherwise false
  15487. */
  15488. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15489. /**
  15490. * Binds the world matrix to the material
  15491. * @param world defines the world transformation matrix
  15492. */
  15493. bindOnlyWorldMatrix(world: Matrix): void;
  15494. /**
  15495. * Binds the material to the mesh
  15496. * @param world defines the world transformation matrix
  15497. * @param mesh defines the mesh to bind the material to
  15498. */
  15499. bind(world: Matrix, mesh?: Mesh): void;
  15500. /**
  15501. * Gets the active textures from the material
  15502. * @returns an array of textures
  15503. */
  15504. getActiveTextures(): BaseTexture[];
  15505. /**
  15506. * Specifies if the material uses a texture
  15507. * @param texture defines the texture to check against the material
  15508. * @returns a boolean specifying if the material uses the texture
  15509. */
  15510. hasTexture(texture: BaseTexture): boolean;
  15511. /**
  15512. * Makes a duplicate of the material, and gives it a new name
  15513. * @param name defines the new name for the duplicated material
  15514. * @returns the cloned material
  15515. */
  15516. clone(name: string): ShaderMaterial;
  15517. /**
  15518. * Disposes the material
  15519. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15520. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15521. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15522. */
  15523. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15524. /**
  15525. * Serializes this material in a JSON representation
  15526. * @returns the serialized material object
  15527. */
  15528. serialize(): any;
  15529. /**
  15530. * Creates a shader material from parsed shader material data
  15531. * @param source defines the JSON represnetation of the material
  15532. * @param scene defines the hosting scene
  15533. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15534. * @returns a new material
  15535. */
  15536. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15537. }
  15538. }
  15539. declare module BABYLON {
  15540. /** @hidden */
  15541. export var colorPixelShader: {
  15542. name: string;
  15543. shader: string;
  15544. };
  15545. }
  15546. declare module BABYLON {
  15547. /** @hidden */
  15548. export var colorVertexShader: {
  15549. name: string;
  15550. shader: string;
  15551. };
  15552. }
  15553. declare module BABYLON {
  15554. /**
  15555. * Line mesh
  15556. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15557. */
  15558. export class LinesMesh extends Mesh {
  15559. /**
  15560. * If vertex color should be applied to the mesh
  15561. */
  15562. readonly useVertexColor?: boolean | undefined;
  15563. /**
  15564. * If vertex alpha should be applied to the mesh
  15565. */
  15566. readonly useVertexAlpha?: boolean | undefined;
  15567. /**
  15568. * Color of the line (Default: White)
  15569. */
  15570. color: Color3;
  15571. /**
  15572. * Alpha of the line (Default: 1)
  15573. */
  15574. alpha: number;
  15575. /**
  15576. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15577. * This margin is expressed in world space coordinates, so its value may vary.
  15578. * Default value is 0.1
  15579. */
  15580. intersectionThreshold: number;
  15581. private _colorShader;
  15582. private color4;
  15583. /**
  15584. * Creates a new LinesMesh
  15585. * @param name defines the name
  15586. * @param scene defines the hosting scene
  15587. * @param parent defines the parent mesh if any
  15588. * @param source defines the optional source LinesMesh used to clone data from
  15589. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15590. * When false, achieved by calling a clone(), also passing False.
  15591. * This will make creation of children, recursive.
  15592. * @param useVertexColor defines if this LinesMesh supports vertex color
  15593. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15594. */
  15595. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15596. /**
  15597. * If vertex color should be applied to the mesh
  15598. */
  15599. useVertexColor?: boolean | undefined,
  15600. /**
  15601. * If vertex alpha should be applied to the mesh
  15602. */
  15603. useVertexAlpha?: boolean | undefined);
  15604. private _addClipPlaneDefine;
  15605. private _removeClipPlaneDefine;
  15606. isReady(): boolean;
  15607. /**
  15608. * Returns the string "LineMesh"
  15609. */
  15610. getClassName(): string;
  15611. /**
  15612. * @hidden
  15613. */
  15614. get material(): Material;
  15615. /**
  15616. * @hidden
  15617. */
  15618. set material(value: Material);
  15619. /**
  15620. * @hidden
  15621. */
  15622. get checkCollisions(): boolean;
  15623. /** @hidden */
  15624. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15625. /** @hidden */
  15626. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15627. /**
  15628. * Disposes of the line mesh
  15629. * @param doNotRecurse If children should be disposed
  15630. */
  15631. dispose(doNotRecurse?: boolean): void;
  15632. /**
  15633. * Returns a new LineMesh object cloned from the current one.
  15634. */
  15635. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15636. /**
  15637. * Creates a new InstancedLinesMesh object from the mesh model.
  15638. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15639. * @param name defines the name of the new instance
  15640. * @returns a new InstancedLinesMesh
  15641. */
  15642. createInstance(name: string): InstancedLinesMesh;
  15643. }
  15644. /**
  15645. * Creates an instance based on a source LinesMesh
  15646. */
  15647. export class InstancedLinesMesh extends InstancedMesh {
  15648. /**
  15649. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15650. * This margin is expressed in world space coordinates, so its value may vary.
  15651. * Initilized with the intersectionThreshold value of the source LinesMesh
  15652. */
  15653. intersectionThreshold: number;
  15654. constructor(name: string, source: LinesMesh);
  15655. /**
  15656. * Returns the string "InstancedLinesMesh".
  15657. */
  15658. getClassName(): string;
  15659. }
  15660. }
  15661. declare module BABYLON {
  15662. /** @hidden */
  15663. export var linePixelShader: {
  15664. name: string;
  15665. shader: string;
  15666. };
  15667. }
  15668. declare module BABYLON {
  15669. /** @hidden */
  15670. export var lineVertexShader: {
  15671. name: string;
  15672. shader: string;
  15673. };
  15674. }
  15675. declare module BABYLON {
  15676. interface AbstractMesh {
  15677. /**
  15678. * Gets the edgesRenderer associated with the mesh
  15679. */
  15680. edgesRenderer: Nullable<EdgesRenderer>;
  15681. }
  15682. interface LinesMesh {
  15683. /**
  15684. * Enables the edge rendering mode on the mesh.
  15685. * This mode makes the mesh edges visible
  15686. * @param epsilon defines the maximal distance between two angles to detect a face
  15687. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15688. * @returns the currentAbstractMesh
  15689. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15690. */
  15691. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15692. }
  15693. interface InstancedLinesMesh {
  15694. /**
  15695. * Enables the edge rendering mode on the mesh.
  15696. * This mode makes the mesh edges visible
  15697. * @param epsilon defines the maximal distance between two angles to detect a face
  15698. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15699. * @returns the current InstancedLinesMesh
  15700. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15701. */
  15702. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15703. }
  15704. /**
  15705. * Defines the minimum contract an Edges renderer should follow.
  15706. */
  15707. export interface IEdgesRenderer extends IDisposable {
  15708. /**
  15709. * Gets or sets a boolean indicating if the edgesRenderer is active
  15710. */
  15711. isEnabled: boolean;
  15712. /**
  15713. * Renders the edges of the attached mesh,
  15714. */
  15715. render(): void;
  15716. /**
  15717. * Checks wether or not the edges renderer is ready to render.
  15718. * @return true if ready, otherwise false.
  15719. */
  15720. isReady(): boolean;
  15721. }
  15722. /**
  15723. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15724. */
  15725. export class EdgesRenderer implements IEdgesRenderer {
  15726. /**
  15727. * Define the size of the edges with an orthographic camera
  15728. */
  15729. edgesWidthScalerForOrthographic: number;
  15730. /**
  15731. * Define the size of the edges with a perspective camera
  15732. */
  15733. edgesWidthScalerForPerspective: number;
  15734. protected _source: AbstractMesh;
  15735. protected _linesPositions: number[];
  15736. protected _linesNormals: number[];
  15737. protected _linesIndices: number[];
  15738. protected _epsilon: number;
  15739. protected _indicesCount: number;
  15740. protected _lineShader: ShaderMaterial;
  15741. protected _ib: DataBuffer;
  15742. protected _buffers: {
  15743. [key: string]: Nullable<VertexBuffer>;
  15744. };
  15745. protected _checkVerticesInsteadOfIndices: boolean;
  15746. private _meshRebuildObserver;
  15747. private _meshDisposeObserver;
  15748. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15749. isEnabled: boolean;
  15750. /**
  15751. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15752. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15753. * @param source Mesh used to create edges
  15754. * @param epsilon sum of angles in adjacency to check for edge
  15755. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15756. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15757. */
  15758. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15759. protected _prepareRessources(): void;
  15760. /** @hidden */
  15761. _rebuild(): void;
  15762. /**
  15763. * Releases the required resources for the edges renderer
  15764. */
  15765. dispose(): void;
  15766. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15767. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15768. /**
  15769. * Checks if the pair of p0 and p1 is en edge
  15770. * @param faceIndex
  15771. * @param edge
  15772. * @param faceNormals
  15773. * @param p0
  15774. * @param p1
  15775. * @private
  15776. */
  15777. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15778. /**
  15779. * push line into the position, normal and index buffer
  15780. * @protected
  15781. */
  15782. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15783. /**
  15784. * Generates lines edges from adjacencjes
  15785. * @private
  15786. */
  15787. _generateEdgesLines(): void;
  15788. /**
  15789. * Checks wether or not the edges renderer is ready to render.
  15790. * @return true if ready, otherwise false.
  15791. */
  15792. isReady(): boolean;
  15793. /**
  15794. * Renders the edges of the attached mesh,
  15795. */
  15796. render(): void;
  15797. }
  15798. /**
  15799. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15800. */
  15801. export class LineEdgesRenderer extends EdgesRenderer {
  15802. /**
  15803. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15804. * @param source LineMesh used to generate edges
  15805. * @param epsilon not important (specified angle for edge detection)
  15806. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15807. */
  15808. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15809. /**
  15810. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15811. */
  15812. _generateEdgesLines(): void;
  15813. }
  15814. }
  15815. declare module BABYLON {
  15816. /**
  15817. * This represents the object necessary to create a rendering group.
  15818. * This is exclusively used and created by the rendering manager.
  15819. * To modify the behavior, you use the available helpers in your scene or meshes.
  15820. * @hidden
  15821. */
  15822. export class RenderingGroup {
  15823. index: number;
  15824. private static _zeroVector;
  15825. private _scene;
  15826. private _opaqueSubMeshes;
  15827. private _transparentSubMeshes;
  15828. private _alphaTestSubMeshes;
  15829. private _depthOnlySubMeshes;
  15830. private _particleSystems;
  15831. private _spriteManagers;
  15832. private _opaqueSortCompareFn;
  15833. private _alphaTestSortCompareFn;
  15834. private _transparentSortCompareFn;
  15835. private _renderOpaque;
  15836. private _renderAlphaTest;
  15837. private _renderTransparent;
  15838. /** @hidden */
  15839. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15840. onBeforeTransparentRendering: () => void;
  15841. /**
  15842. * Set the opaque sort comparison function.
  15843. * If null the sub meshes will be render in the order they were created
  15844. */
  15845. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15846. /**
  15847. * Set the alpha test sort comparison function.
  15848. * If null the sub meshes will be render in the order they were created
  15849. */
  15850. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15851. /**
  15852. * Set the transparent sort comparison function.
  15853. * If null the sub meshes will be render in the order they were created
  15854. */
  15855. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15856. /**
  15857. * Creates a new rendering group.
  15858. * @param index The rendering group index
  15859. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15860. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15861. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15862. */
  15863. 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>);
  15864. /**
  15865. * Render all the sub meshes contained in the group.
  15866. * @param customRenderFunction Used to override the default render behaviour of the group.
  15867. * @returns true if rendered some submeshes.
  15868. */
  15869. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15870. /**
  15871. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15872. * @param subMeshes The submeshes to render
  15873. */
  15874. private renderOpaqueSorted;
  15875. /**
  15876. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15877. * @param subMeshes The submeshes to render
  15878. */
  15879. private renderAlphaTestSorted;
  15880. /**
  15881. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15882. * @param subMeshes The submeshes to render
  15883. */
  15884. private renderTransparentSorted;
  15885. /**
  15886. * Renders the submeshes in a specified order.
  15887. * @param subMeshes The submeshes to sort before render
  15888. * @param sortCompareFn The comparison function use to sort
  15889. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15890. * @param transparent Specifies to activate blending if true
  15891. */
  15892. private static renderSorted;
  15893. /**
  15894. * Renders the submeshes in the order they were dispatched (no sort applied).
  15895. * @param subMeshes The submeshes to render
  15896. */
  15897. private static renderUnsorted;
  15898. /**
  15899. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15900. * are rendered back to front if in the same alpha index.
  15901. *
  15902. * @param a The first submesh
  15903. * @param b The second submesh
  15904. * @returns The result of the comparison
  15905. */
  15906. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15907. /**
  15908. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15909. * are rendered back to front.
  15910. *
  15911. * @param a The first submesh
  15912. * @param b The second submesh
  15913. * @returns The result of the comparison
  15914. */
  15915. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15916. /**
  15917. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15918. * are rendered front to back (prevent overdraw).
  15919. *
  15920. * @param a The first submesh
  15921. * @param b The second submesh
  15922. * @returns The result of the comparison
  15923. */
  15924. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15925. /**
  15926. * Resets the different lists of submeshes to prepare a new frame.
  15927. */
  15928. prepare(): void;
  15929. dispose(): void;
  15930. /**
  15931. * Inserts the submesh in its correct queue depending on its material.
  15932. * @param subMesh The submesh to dispatch
  15933. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15934. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15935. */
  15936. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15937. dispatchSprites(spriteManager: ISpriteManager): void;
  15938. dispatchParticles(particleSystem: IParticleSystem): void;
  15939. private _renderParticles;
  15940. private _renderSprites;
  15941. }
  15942. }
  15943. declare module BABYLON {
  15944. /**
  15945. * Interface describing the different options available in the rendering manager
  15946. * regarding Auto Clear between groups.
  15947. */
  15948. export interface IRenderingManagerAutoClearSetup {
  15949. /**
  15950. * Defines whether or not autoclear is enable.
  15951. */
  15952. autoClear: boolean;
  15953. /**
  15954. * Defines whether or not to autoclear the depth buffer.
  15955. */
  15956. depth: boolean;
  15957. /**
  15958. * Defines whether or not to autoclear the stencil buffer.
  15959. */
  15960. stencil: boolean;
  15961. }
  15962. /**
  15963. * This class is used by the onRenderingGroupObservable
  15964. */
  15965. export class RenderingGroupInfo {
  15966. /**
  15967. * The Scene that being rendered
  15968. */
  15969. scene: Scene;
  15970. /**
  15971. * The camera currently used for the rendering pass
  15972. */
  15973. camera: Nullable<Camera>;
  15974. /**
  15975. * The ID of the renderingGroup being processed
  15976. */
  15977. renderingGroupId: number;
  15978. }
  15979. /**
  15980. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15981. * It is enable to manage the different groups as well as the different necessary sort functions.
  15982. * This should not be used directly aside of the few static configurations
  15983. */
  15984. export class RenderingManager {
  15985. /**
  15986. * The max id used for rendering groups (not included)
  15987. */
  15988. static MAX_RENDERINGGROUPS: number;
  15989. /**
  15990. * The min id used for rendering groups (included)
  15991. */
  15992. static MIN_RENDERINGGROUPS: number;
  15993. /**
  15994. * Used to globally prevent autoclearing scenes.
  15995. */
  15996. static AUTOCLEAR: boolean;
  15997. /**
  15998. * @hidden
  15999. */
  16000. _useSceneAutoClearSetup: boolean;
  16001. private _scene;
  16002. private _renderingGroups;
  16003. private _depthStencilBufferAlreadyCleaned;
  16004. private _autoClearDepthStencil;
  16005. private _customOpaqueSortCompareFn;
  16006. private _customAlphaTestSortCompareFn;
  16007. private _customTransparentSortCompareFn;
  16008. private _renderingGroupInfo;
  16009. /**
  16010. * Instantiates a new rendering group for a particular scene
  16011. * @param scene Defines the scene the groups belongs to
  16012. */
  16013. constructor(scene: Scene);
  16014. private _clearDepthStencilBuffer;
  16015. /**
  16016. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16017. * @hidden
  16018. */
  16019. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16020. /**
  16021. * Resets the different information of the group to prepare a new frame
  16022. * @hidden
  16023. */
  16024. reset(): void;
  16025. /**
  16026. * Dispose and release the group and its associated resources.
  16027. * @hidden
  16028. */
  16029. dispose(): void;
  16030. /**
  16031. * Clear the info related to rendering groups preventing retention points during dispose.
  16032. */
  16033. freeRenderingGroups(): void;
  16034. private _prepareRenderingGroup;
  16035. /**
  16036. * Add a sprite manager to the rendering manager in order to render it this frame.
  16037. * @param spriteManager Define the sprite manager to render
  16038. */
  16039. dispatchSprites(spriteManager: ISpriteManager): void;
  16040. /**
  16041. * Add a particle system to the rendering manager in order to render it this frame.
  16042. * @param particleSystem Define the particle system to render
  16043. */
  16044. dispatchParticles(particleSystem: IParticleSystem): void;
  16045. /**
  16046. * Add a submesh to the manager in order to render it this frame
  16047. * @param subMesh The submesh to dispatch
  16048. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16049. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16050. */
  16051. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16052. /**
  16053. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16054. * This allowed control for front to back rendering or reversly depending of the special needs.
  16055. *
  16056. * @param renderingGroupId The rendering group id corresponding to its index
  16057. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16058. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16059. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16060. */
  16061. 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;
  16062. /**
  16063. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16064. *
  16065. * @param renderingGroupId The rendering group id corresponding to its index
  16066. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16067. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16068. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16069. */
  16070. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16071. /**
  16072. * Gets the current auto clear configuration for one rendering group of the rendering
  16073. * manager.
  16074. * @param index the rendering group index to get the information for
  16075. * @returns The auto clear setup for the requested rendering group
  16076. */
  16077. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16078. }
  16079. }
  16080. declare module BABYLON {
  16081. /**
  16082. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16083. */
  16084. export interface ICustomShaderOptions {
  16085. /**
  16086. * Gets or sets the custom shader name to use
  16087. */
  16088. shaderName: string;
  16089. /**
  16090. * The list of attribute names used in the shader
  16091. */
  16092. attributes?: string[];
  16093. /**
  16094. * The list of unifrom names used in the shader
  16095. */
  16096. uniforms?: string[];
  16097. /**
  16098. * The list of sampler names used in the shader
  16099. */
  16100. samplers?: string[];
  16101. /**
  16102. * The list of defines used in the shader
  16103. */
  16104. defines?: string[];
  16105. }
  16106. /**
  16107. * Interface to implement to create a shadow generator compatible with BJS.
  16108. */
  16109. export interface IShadowGenerator {
  16110. /**
  16111. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16112. * @returns The render target texture if present otherwise, null
  16113. */
  16114. getShadowMap(): Nullable<RenderTargetTexture>;
  16115. /**
  16116. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16117. * @param subMesh The submesh we want to render in the shadow map
  16118. * @param useInstances Defines wether will draw in the map using instances
  16119. * @returns true if ready otherwise, false
  16120. */
  16121. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16122. /**
  16123. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16124. * @param defines Defines of the material we want to update
  16125. * @param lightIndex Index of the light in the enabled light list of the material
  16126. */
  16127. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16128. /**
  16129. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16130. * defined in the generator but impacting the effect).
  16131. * It implies the unifroms available on the materials are the standard BJS ones.
  16132. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16133. * @param effect The effect we are binfing the information for
  16134. */
  16135. bindShadowLight(lightIndex: string, effect: Effect): void;
  16136. /**
  16137. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16138. * (eq to shadow prjection matrix * light transform matrix)
  16139. * @returns The transform matrix used to create the shadow map
  16140. */
  16141. getTransformMatrix(): Matrix;
  16142. /**
  16143. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16144. * Cube and 2D textures for instance.
  16145. */
  16146. recreateShadowMap(): void;
  16147. /**
  16148. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16149. * @param onCompiled Callback triggered at the and of the effects compilation
  16150. * @param options Sets of optional options forcing the compilation with different modes
  16151. */
  16152. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16153. useInstances: boolean;
  16154. }>): void;
  16155. /**
  16156. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16157. * @param options Sets of optional options forcing the compilation with different modes
  16158. * @returns A promise that resolves when the compilation completes
  16159. */
  16160. forceCompilationAsync(options?: Partial<{
  16161. useInstances: boolean;
  16162. }>): Promise<void>;
  16163. /**
  16164. * Serializes the shadow generator setup to a json object.
  16165. * @returns The serialized JSON object
  16166. */
  16167. serialize(): any;
  16168. /**
  16169. * Disposes the Shadow map and related Textures and effects.
  16170. */
  16171. dispose(): void;
  16172. }
  16173. /**
  16174. * Default implementation IShadowGenerator.
  16175. * This is the main object responsible of generating shadows in the framework.
  16176. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16177. */
  16178. export class ShadowGenerator implements IShadowGenerator {
  16179. /**
  16180. * Name of the shadow generator class
  16181. */
  16182. static CLASSNAME: string;
  16183. /**
  16184. * Shadow generator mode None: no filtering applied.
  16185. */
  16186. static readonly FILTER_NONE: number;
  16187. /**
  16188. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16189. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16190. */
  16191. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16192. /**
  16193. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16194. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16195. */
  16196. static readonly FILTER_POISSONSAMPLING: number;
  16197. /**
  16198. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16199. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16200. */
  16201. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16202. /**
  16203. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16204. * edge artifacts on steep falloff.
  16205. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16206. */
  16207. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16208. /**
  16209. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16210. * edge artifacts on steep falloff.
  16211. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16212. */
  16213. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16214. /**
  16215. * Shadow generator mode PCF: Percentage Closer Filtering
  16216. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16217. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16218. */
  16219. static readonly FILTER_PCF: number;
  16220. /**
  16221. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16222. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16223. * Contact Hardening
  16224. */
  16225. static readonly FILTER_PCSS: number;
  16226. /**
  16227. * Reserved for PCF and PCSS
  16228. * Highest Quality.
  16229. *
  16230. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16231. *
  16232. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16233. */
  16234. static readonly QUALITY_HIGH: number;
  16235. /**
  16236. * Reserved for PCF and PCSS
  16237. * Good tradeoff for quality/perf cross devices
  16238. *
  16239. * Execute PCF on a 3*3 kernel.
  16240. *
  16241. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16242. */
  16243. static readonly QUALITY_MEDIUM: number;
  16244. /**
  16245. * Reserved for PCF and PCSS
  16246. * The lowest quality but the fastest.
  16247. *
  16248. * Execute PCF on a 1*1 kernel.
  16249. *
  16250. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16251. */
  16252. static readonly QUALITY_LOW: number;
  16253. /** Gets or sets the custom shader name to use */
  16254. customShaderOptions: ICustomShaderOptions;
  16255. /**
  16256. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16257. */
  16258. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16259. /**
  16260. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16261. */
  16262. onAfterShadowMapRenderObservable: Observable<Effect>;
  16263. /**
  16264. * Observable triggered before a mesh is rendered in the shadow map.
  16265. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16266. */
  16267. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16268. /**
  16269. * Observable triggered after a mesh is rendered in the shadow map.
  16270. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16271. */
  16272. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16273. protected _bias: number;
  16274. /**
  16275. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16276. */
  16277. get bias(): number;
  16278. /**
  16279. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16280. */
  16281. set bias(bias: number);
  16282. protected _normalBias: number;
  16283. /**
  16284. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16285. */
  16286. get normalBias(): number;
  16287. /**
  16288. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16289. */
  16290. set normalBias(normalBias: number);
  16291. protected _blurBoxOffset: number;
  16292. /**
  16293. * Gets the blur box offset: offset applied during the blur pass.
  16294. * Only useful if useKernelBlur = false
  16295. */
  16296. get blurBoxOffset(): number;
  16297. /**
  16298. * Sets the blur box offset: offset applied during the blur pass.
  16299. * Only useful if useKernelBlur = false
  16300. */
  16301. set blurBoxOffset(value: number);
  16302. protected _blurScale: number;
  16303. /**
  16304. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16305. * 2 means half of the size.
  16306. */
  16307. get blurScale(): number;
  16308. /**
  16309. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16310. * 2 means half of the size.
  16311. */
  16312. set blurScale(value: number);
  16313. protected _blurKernel: number;
  16314. /**
  16315. * Gets the blur kernel: kernel size of the blur pass.
  16316. * Only useful if useKernelBlur = true
  16317. */
  16318. get blurKernel(): number;
  16319. /**
  16320. * Sets the blur kernel: kernel size of the blur pass.
  16321. * Only useful if useKernelBlur = true
  16322. */
  16323. set blurKernel(value: number);
  16324. protected _useKernelBlur: boolean;
  16325. /**
  16326. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16327. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16328. */
  16329. get useKernelBlur(): boolean;
  16330. /**
  16331. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16332. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16333. */
  16334. set useKernelBlur(value: boolean);
  16335. protected _depthScale: number;
  16336. /**
  16337. * Gets the depth scale used in ESM mode.
  16338. */
  16339. get depthScale(): number;
  16340. /**
  16341. * Sets the depth scale used in ESM mode.
  16342. * This can override the scale stored on the light.
  16343. */
  16344. set depthScale(value: number);
  16345. protected _validateFilter(filter: number): number;
  16346. protected _filter: number;
  16347. /**
  16348. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16349. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16350. */
  16351. get filter(): number;
  16352. /**
  16353. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16354. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16355. */
  16356. set filter(value: number);
  16357. /**
  16358. * Gets if the current filter is set to Poisson Sampling.
  16359. */
  16360. get usePoissonSampling(): boolean;
  16361. /**
  16362. * Sets the current filter to Poisson Sampling.
  16363. */
  16364. set usePoissonSampling(value: boolean);
  16365. /**
  16366. * Gets if the current filter is set to ESM.
  16367. */
  16368. get useExponentialShadowMap(): boolean;
  16369. /**
  16370. * Sets the current filter is to ESM.
  16371. */
  16372. set useExponentialShadowMap(value: boolean);
  16373. /**
  16374. * Gets if the current filter is set to filtered ESM.
  16375. */
  16376. get useBlurExponentialShadowMap(): boolean;
  16377. /**
  16378. * Gets if the current filter is set to filtered ESM.
  16379. */
  16380. set useBlurExponentialShadowMap(value: boolean);
  16381. /**
  16382. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16383. * exponential to prevent steep falloff artifacts).
  16384. */
  16385. get useCloseExponentialShadowMap(): boolean;
  16386. /**
  16387. * Sets the current filter to "close ESM" (using the inverse of the
  16388. * exponential to prevent steep falloff artifacts).
  16389. */
  16390. set useCloseExponentialShadowMap(value: boolean);
  16391. /**
  16392. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16393. * exponential to prevent steep falloff artifacts).
  16394. */
  16395. get useBlurCloseExponentialShadowMap(): boolean;
  16396. /**
  16397. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16398. * exponential to prevent steep falloff artifacts).
  16399. */
  16400. set useBlurCloseExponentialShadowMap(value: boolean);
  16401. /**
  16402. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16403. */
  16404. get usePercentageCloserFiltering(): boolean;
  16405. /**
  16406. * Sets the current filter to "PCF" (percentage closer filtering).
  16407. */
  16408. set usePercentageCloserFiltering(value: boolean);
  16409. protected _filteringQuality: number;
  16410. /**
  16411. * Gets the PCF or PCSS Quality.
  16412. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16413. */
  16414. get filteringQuality(): number;
  16415. /**
  16416. * Sets the PCF or PCSS Quality.
  16417. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16418. */
  16419. set filteringQuality(filteringQuality: number);
  16420. /**
  16421. * Gets if the current filter is set to "PCSS" (contact hardening).
  16422. */
  16423. get useContactHardeningShadow(): boolean;
  16424. /**
  16425. * Sets the current filter to "PCSS" (contact hardening).
  16426. */
  16427. set useContactHardeningShadow(value: boolean);
  16428. protected _contactHardeningLightSizeUVRatio: number;
  16429. /**
  16430. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16431. * Using a ratio helps keeping shape stability independently of the map size.
  16432. *
  16433. * It does not account for the light projection as it was having too much
  16434. * instability during the light setup or during light position changes.
  16435. *
  16436. * Only valid if useContactHardeningShadow is true.
  16437. */
  16438. get contactHardeningLightSizeUVRatio(): number;
  16439. /**
  16440. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16441. * Using a ratio helps keeping shape stability independently of the map size.
  16442. *
  16443. * It does not account for the light projection as it was having too much
  16444. * instability during the light setup or during light position changes.
  16445. *
  16446. * Only valid if useContactHardeningShadow is true.
  16447. */
  16448. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16449. protected _darkness: number;
  16450. /** Gets or sets the actual darkness of a shadow */
  16451. get darkness(): number;
  16452. set darkness(value: number);
  16453. /**
  16454. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16455. * 0 means strongest and 1 would means no shadow.
  16456. * @returns the darkness.
  16457. */
  16458. getDarkness(): number;
  16459. /**
  16460. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16461. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16462. * @returns the shadow generator allowing fluent coding.
  16463. */
  16464. setDarkness(darkness: number): ShadowGenerator;
  16465. protected _transparencyShadow: boolean;
  16466. /** Gets or sets the ability to have transparent shadow */
  16467. get transparencyShadow(): boolean;
  16468. set transparencyShadow(value: boolean);
  16469. /**
  16470. * Sets the ability to have transparent shadow (boolean).
  16471. * @param transparent True if transparent else False
  16472. * @returns the shadow generator allowing fluent coding
  16473. */
  16474. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16475. protected _shadowMap: Nullable<RenderTargetTexture>;
  16476. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16477. /**
  16478. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16479. * @returns The render target texture if present otherwise, null
  16480. */
  16481. getShadowMap(): Nullable<RenderTargetTexture>;
  16482. /**
  16483. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16484. * @returns The render target texture if the shadow map is present otherwise, null
  16485. */
  16486. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16487. /**
  16488. * Gets the class name of that object
  16489. * @returns "ShadowGenerator"
  16490. */
  16491. getClassName(): string;
  16492. /**
  16493. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16494. * @param mesh Mesh to add
  16495. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16496. * @returns the Shadow Generator itself
  16497. */
  16498. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16499. /**
  16500. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16501. * @param mesh Mesh to remove
  16502. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16503. * @returns the Shadow Generator itself
  16504. */
  16505. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16506. /**
  16507. * Controls the extent to which the shadows fade out at the edge of the frustum
  16508. */
  16509. frustumEdgeFalloff: number;
  16510. protected _light: IShadowLight;
  16511. /**
  16512. * Returns the associated light object.
  16513. * @returns the light generating the shadow
  16514. */
  16515. getLight(): IShadowLight;
  16516. /**
  16517. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16518. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16519. * It might on the other hand introduce peter panning.
  16520. */
  16521. forceBackFacesOnly: boolean;
  16522. protected _scene: Scene;
  16523. protected _lightDirection: Vector3;
  16524. protected _effect: Effect;
  16525. protected _viewMatrix: Matrix;
  16526. protected _projectionMatrix: Matrix;
  16527. protected _transformMatrix: Matrix;
  16528. protected _cachedPosition: Vector3;
  16529. protected _cachedDirection: Vector3;
  16530. protected _cachedDefines: string;
  16531. protected _currentRenderID: number;
  16532. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16533. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16534. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16535. protected _blurPostProcesses: PostProcess[];
  16536. protected _mapSize: number;
  16537. protected _currentFaceIndex: number;
  16538. protected _currentFaceIndexCache: number;
  16539. protected _textureType: number;
  16540. protected _defaultTextureMatrix: Matrix;
  16541. protected _storedUniqueId: Nullable<number>;
  16542. /** @hidden */
  16543. static _SceneComponentInitialization: (scene: Scene) => void;
  16544. /**
  16545. * Creates a ShadowGenerator object.
  16546. * A ShadowGenerator is the required tool to use the shadows.
  16547. * Each light casting shadows needs to use its own ShadowGenerator.
  16548. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16549. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16550. * @param light The light object generating the shadows.
  16551. * @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.
  16552. */
  16553. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16554. protected _initializeGenerator(): void;
  16555. protected _createTargetRenderTexture(): void;
  16556. protected _initializeShadowMap(): void;
  16557. protected _initializeBlurRTTAndPostProcesses(): void;
  16558. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16559. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16560. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16561. protected _applyFilterValues(): void;
  16562. /**
  16563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16564. * @param onCompiled Callback triggered at the and of the effects compilation
  16565. * @param options Sets of optional options forcing the compilation with different modes
  16566. */
  16567. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16568. useInstances: boolean;
  16569. }>): void;
  16570. /**
  16571. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16572. * @param options Sets of optional options forcing the compilation with different modes
  16573. * @returns A promise that resolves when the compilation completes
  16574. */
  16575. forceCompilationAsync(options?: Partial<{
  16576. useInstances: boolean;
  16577. }>): Promise<void>;
  16578. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16579. /**
  16580. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16581. * @param subMesh The submesh we want to render in the shadow map
  16582. * @param useInstances Defines wether will draw in the map using instances
  16583. * @returns true if ready otherwise, false
  16584. */
  16585. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16586. /**
  16587. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16588. * @param defines Defines of the material we want to update
  16589. * @param lightIndex Index of the light in the enabled light list of the material
  16590. */
  16591. prepareDefines(defines: any, lightIndex: number): void;
  16592. /**
  16593. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16594. * defined in the generator but impacting the effect).
  16595. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16596. * @param effect The effect we are binfing the information for
  16597. */
  16598. bindShadowLight(lightIndex: string, effect: Effect): void;
  16599. /**
  16600. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16601. * (eq to shadow prjection matrix * light transform matrix)
  16602. * @returns The transform matrix used to create the shadow map
  16603. */
  16604. getTransformMatrix(): Matrix;
  16605. /**
  16606. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16607. * Cube and 2D textures for instance.
  16608. */
  16609. recreateShadowMap(): void;
  16610. protected _disposeBlurPostProcesses(): void;
  16611. protected _disposeRTTandPostProcesses(): void;
  16612. /**
  16613. * Disposes the ShadowGenerator.
  16614. * Returns nothing.
  16615. */
  16616. dispose(): void;
  16617. /**
  16618. * Serializes the shadow generator setup to a json object.
  16619. * @returns The serialized JSON object
  16620. */
  16621. serialize(): any;
  16622. /**
  16623. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16624. * @param parsedShadowGenerator The JSON object to parse
  16625. * @param scene The scene to create the shadow map for
  16626. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16627. * @returns The parsed shadow generator
  16628. */
  16629. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16630. }
  16631. }
  16632. declare module BABYLON {
  16633. /**
  16634. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16635. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16636. * 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.
  16637. */
  16638. export abstract class Light extends Node {
  16639. /**
  16640. * Falloff Default: light is falling off following the material specification:
  16641. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16642. */
  16643. static readonly FALLOFF_DEFAULT: number;
  16644. /**
  16645. * Falloff Physical: light is falling off following the inverse squared distance law.
  16646. */
  16647. static readonly FALLOFF_PHYSICAL: number;
  16648. /**
  16649. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16650. * to enhance interoperability with other engines.
  16651. */
  16652. static readonly FALLOFF_GLTF: number;
  16653. /**
  16654. * Falloff Standard: light is falling off like in the standard material
  16655. * to enhance interoperability with other materials.
  16656. */
  16657. static readonly FALLOFF_STANDARD: number;
  16658. /**
  16659. * If every light affecting the material is in this lightmapMode,
  16660. * material.lightmapTexture adds or multiplies
  16661. * (depends on material.useLightmapAsShadowmap)
  16662. * after every other light calculations.
  16663. */
  16664. static readonly LIGHTMAP_DEFAULT: number;
  16665. /**
  16666. * material.lightmapTexture as only diffuse lighting from this light
  16667. * adds only specular lighting from this light
  16668. * adds dynamic shadows
  16669. */
  16670. static readonly LIGHTMAP_SPECULAR: number;
  16671. /**
  16672. * material.lightmapTexture as only lighting
  16673. * no light calculation from this light
  16674. * only adds dynamic shadows from this light
  16675. */
  16676. static readonly LIGHTMAP_SHADOWSONLY: number;
  16677. /**
  16678. * Each light type uses the default quantity according to its type:
  16679. * point/spot lights use luminous intensity
  16680. * directional lights use illuminance
  16681. */
  16682. static readonly INTENSITYMODE_AUTOMATIC: number;
  16683. /**
  16684. * lumen (lm)
  16685. */
  16686. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16687. /**
  16688. * candela (lm/sr)
  16689. */
  16690. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16691. /**
  16692. * lux (lm/m^2)
  16693. */
  16694. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16695. /**
  16696. * nit (cd/m^2)
  16697. */
  16698. static readonly INTENSITYMODE_LUMINANCE: number;
  16699. /**
  16700. * Light type const id of the point light.
  16701. */
  16702. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16703. /**
  16704. * Light type const id of the directional light.
  16705. */
  16706. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16707. /**
  16708. * Light type const id of the spot light.
  16709. */
  16710. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16711. /**
  16712. * Light type const id of the hemispheric light.
  16713. */
  16714. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16715. /**
  16716. * Diffuse gives the basic color to an object.
  16717. */
  16718. diffuse: Color3;
  16719. /**
  16720. * Specular produces a highlight color on an object.
  16721. * Note: This is note affecting PBR materials.
  16722. */
  16723. specular: Color3;
  16724. /**
  16725. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16726. * falling off base on range or angle.
  16727. * This can be set to any values in Light.FALLOFF_x.
  16728. *
  16729. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16730. * other types of materials.
  16731. */
  16732. falloffType: number;
  16733. /**
  16734. * Strength of the light.
  16735. * Note: By default it is define in the framework own unit.
  16736. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16737. */
  16738. intensity: number;
  16739. private _range;
  16740. protected _inverseSquaredRange: number;
  16741. /**
  16742. * Defines how far from the source the light is impacting in scene units.
  16743. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16744. */
  16745. get range(): number;
  16746. /**
  16747. * Defines how far from the source the light is impacting in scene units.
  16748. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16749. */
  16750. set range(value: number);
  16751. /**
  16752. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16753. * of light.
  16754. */
  16755. private _photometricScale;
  16756. private _intensityMode;
  16757. /**
  16758. * Gets the photometric scale used to interpret the intensity.
  16759. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16760. */
  16761. get intensityMode(): number;
  16762. /**
  16763. * Sets the photometric scale used to interpret the intensity.
  16764. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16765. */
  16766. set intensityMode(value: number);
  16767. private _radius;
  16768. /**
  16769. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16770. */
  16771. get radius(): number;
  16772. /**
  16773. * sets the light radius used by PBR Materials to simulate soft area lights.
  16774. */
  16775. set radius(value: number);
  16776. private _renderPriority;
  16777. /**
  16778. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16779. * exceeding the number allowed of the materials.
  16780. */
  16781. renderPriority: number;
  16782. private _shadowEnabled;
  16783. /**
  16784. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16785. * the current shadow generator.
  16786. */
  16787. get shadowEnabled(): boolean;
  16788. /**
  16789. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16790. * the current shadow generator.
  16791. */
  16792. set shadowEnabled(value: boolean);
  16793. private _includedOnlyMeshes;
  16794. /**
  16795. * Gets the only meshes impacted by this light.
  16796. */
  16797. get includedOnlyMeshes(): AbstractMesh[];
  16798. /**
  16799. * Sets the only meshes impacted by this light.
  16800. */
  16801. set includedOnlyMeshes(value: AbstractMesh[]);
  16802. private _excludedMeshes;
  16803. /**
  16804. * Gets the meshes not impacted by this light.
  16805. */
  16806. get excludedMeshes(): AbstractMesh[];
  16807. /**
  16808. * Sets the meshes not impacted by this light.
  16809. */
  16810. set excludedMeshes(value: AbstractMesh[]);
  16811. private _excludeWithLayerMask;
  16812. /**
  16813. * Gets the layer id use to find what meshes are not impacted by the light.
  16814. * Inactive if 0
  16815. */
  16816. get excludeWithLayerMask(): number;
  16817. /**
  16818. * Sets the layer id use to find what meshes are not impacted by the light.
  16819. * Inactive if 0
  16820. */
  16821. set excludeWithLayerMask(value: number);
  16822. private _includeOnlyWithLayerMask;
  16823. /**
  16824. * Gets the layer id use to find what meshes are impacted by the light.
  16825. * Inactive if 0
  16826. */
  16827. get includeOnlyWithLayerMask(): number;
  16828. /**
  16829. * Sets the layer id use to find what meshes are impacted by the light.
  16830. * Inactive if 0
  16831. */
  16832. set includeOnlyWithLayerMask(value: number);
  16833. private _lightmapMode;
  16834. /**
  16835. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16836. */
  16837. get lightmapMode(): number;
  16838. /**
  16839. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16840. */
  16841. set lightmapMode(value: number);
  16842. /**
  16843. * Shadow generator associted to the light.
  16844. * @hidden Internal use only.
  16845. */
  16846. _shadowGenerator: Nullable<IShadowGenerator>;
  16847. /**
  16848. * @hidden Internal use only.
  16849. */
  16850. _excludedMeshesIds: string[];
  16851. /**
  16852. * @hidden Internal use only.
  16853. */
  16854. _includedOnlyMeshesIds: string[];
  16855. /**
  16856. * The current light unifom buffer.
  16857. * @hidden Internal use only.
  16858. */
  16859. _uniformBuffer: UniformBuffer;
  16860. /** @hidden */
  16861. _renderId: number;
  16862. /**
  16863. * Creates a Light object in the scene.
  16864. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16865. * @param name The firendly name of the light
  16866. * @param scene The scene the light belongs too
  16867. */
  16868. constructor(name: string, scene: Scene);
  16869. protected abstract _buildUniformLayout(): void;
  16870. /**
  16871. * Sets the passed Effect "effect" with the Light information.
  16872. * @param effect The effect to update
  16873. * @param lightIndex The index of the light in the effect to update
  16874. * @returns The light
  16875. */
  16876. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16877. /**
  16878. * Sets the passed Effect "effect" with the Light textures.
  16879. * @param effect The effect to update
  16880. * @param lightIndex The index of the light in the effect to update
  16881. * @returns The light
  16882. */
  16883. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16884. /**
  16885. * Binds the lights information from the scene to the effect for the given mesh.
  16886. * @param lightIndex Light index
  16887. * @param scene The scene where the light belongs to
  16888. * @param effect The effect we are binding the data to
  16889. * @param useSpecular Defines if specular is supported
  16890. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16891. */
  16892. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16893. /**
  16894. * Sets the passed Effect "effect" with the Light information.
  16895. * @param effect The effect to update
  16896. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16897. * @returns The light
  16898. */
  16899. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16900. /**
  16901. * Returns the string "Light".
  16902. * @returns the class name
  16903. */
  16904. getClassName(): string;
  16905. /** @hidden */
  16906. readonly _isLight: boolean;
  16907. /**
  16908. * Converts the light information to a readable string for debug purpose.
  16909. * @param fullDetails Supports for multiple levels of logging within scene loading
  16910. * @returns the human readable light info
  16911. */
  16912. toString(fullDetails?: boolean): string;
  16913. /** @hidden */
  16914. protected _syncParentEnabledState(): void;
  16915. /**
  16916. * Set the enabled state of this node.
  16917. * @param value - the new enabled state
  16918. */
  16919. setEnabled(value: boolean): void;
  16920. /**
  16921. * Returns the Light associated shadow generator if any.
  16922. * @return the associated shadow generator.
  16923. */
  16924. getShadowGenerator(): Nullable<IShadowGenerator>;
  16925. /**
  16926. * Returns a Vector3, the absolute light position in the World.
  16927. * @returns the world space position of the light
  16928. */
  16929. getAbsolutePosition(): Vector3;
  16930. /**
  16931. * Specifies if the light will affect the passed mesh.
  16932. * @param mesh The mesh to test against the light
  16933. * @return true the mesh is affected otherwise, false.
  16934. */
  16935. canAffectMesh(mesh: AbstractMesh): boolean;
  16936. /**
  16937. * Sort function to order lights for rendering.
  16938. * @param a First Light object to compare to second.
  16939. * @param b Second Light object to compare first.
  16940. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16941. */
  16942. static CompareLightsPriority(a: Light, b: Light): number;
  16943. /**
  16944. * Releases resources associated with this node.
  16945. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16946. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16947. */
  16948. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16949. /**
  16950. * Returns the light type ID (integer).
  16951. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16952. */
  16953. getTypeID(): number;
  16954. /**
  16955. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16956. * @returns the scaled intensity in intensity mode unit
  16957. */
  16958. getScaledIntensity(): number;
  16959. /**
  16960. * Returns a new Light object, named "name", from the current one.
  16961. * @param name The name of the cloned light
  16962. * @returns the new created light
  16963. */
  16964. clone(name: string): Nullable<Light>;
  16965. /**
  16966. * Serializes the current light into a Serialization object.
  16967. * @returns the serialized object.
  16968. */
  16969. serialize(): any;
  16970. /**
  16971. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16972. * This new light is named "name" and added to the passed scene.
  16973. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16974. * @param name The friendly name of the light
  16975. * @param scene The scene the new light will belong to
  16976. * @returns the constructor function
  16977. */
  16978. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16979. /**
  16980. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16981. * @param parsedLight The JSON representation of the light
  16982. * @param scene The scene to create the parsed light in
  16983. * @returns the created light after parsing
  16984. */
  16985. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16986. private _hookArrayForExcluded;
  16987. private _hookArrayForIncludedOnly;
  16988. private _resyncMeshes;
  16989. /**
  16990. * Forces the meshes to update their light related information in their rendering used effects
  16991. * @hidden Internal Use Only
  16992. */
  16993. _markMeshesAsLightDirty(): void;
  16994. /**
  16995. * Recomputes the cached photometric scale if needed.
  16996. */
  16997. private _computePhotometricScale;
  16998. /**
  16999. * Returns the Photometric Scale according to the light type and intensity mode.
  17000. */
  17001. private _getPhotometricScale;
  17002. /**
  17003. * Reorder the light in the scene according to their defined priority.
  17004. * @hidden Internal Use Only
  17005. */
  17006. _reorderLightsInScene(): void;
  17007. /**
  17008. * Prepares the list of defines specific to the light type.
  17009. * @param defines the list of defines
  17010. * @param lightIndex defines the index of the light for the effect
  17011. */
  17012. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17013. }
  17014. }
  17015. declare module BABYLON {
  17016. /**
  17017. * Interface used to define Action
  17018. */
  17019. export interface IAction {
  17020. /**
  17021. * Trigger for the action
  17022. */
  17023. trigger: number;
  17024. /** Options of the trigger */
  17025. triggerOptions: any;
  17026. /**
  17027. * Gets the trigger parameters
  17028. * @returns the trigger parameters
  17029. */
  17030. getTriggerParameter(): any;
  17031. /**
  17032. * Internal only - executes current action event
  17033. * @hidden
  17034. */
  17035. _executeCurrent(evt?: ActionEvent): void;
  17036. /**
  17037. * Serialize placeholder for child classes
  17038. * @param parent of child
  17039. * @returns the serialized object
  17040. */
  17041. serialize(parent: any): any;
  17042. /**
  17043. * Internal only
  17044. * @hidden
  17045. */
  17046. _prepare(): void;
  17047. /**
  17048. * Internal only - manager for action
  17049. * @hidden
  17050. */
  17051. _actionManager: AbstractActionManager;
  17052. /**
  17053. * Adds action to chain of actions, may be a DoNothingAction
  17054. * @param action defines the next action to execute
  17055. * @returns The action passed in
  17056. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17057. */
  17058. then(action: IAction): IAction;
  17059. }
  17060. /**
  17061. * The action to be carried out following a trigger
  17062. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17063. */
  17064. export class Action implements IAction {
  17065. /** the trigger, with or without parameters, for the action */
  17066. triggerOptions: any;
  17067. /**
  17068. * Trigger for the action
  17069. */
  17070. trigger: number;
  17071. /**
  17072. * Internal only - manager for action
  17073. * @hidden
  17074. */
  17075. _actionManager: ActionManager;
  17076. private _nextActiveAction;
  17077. private _child;
  17078. private _condition?;
  17079. private _triggerParameter;
  17080. /**
  17081. * An event triggered prior to action being executed.
  17082. */
  17083. onBeforeExecuteObservable: Observable<Action>;
  17084. /**
  17085. * Creates a new Action
  17086. * @param triggerOptions the trigger, with or without parameters, for the action
  17087. * @param condition an optional determinant of action
  17088. */
  17089. constructor(
  17090. /** the trigger, with or without parameters, for the action */
  17091. triggerOptions: any, condition?: Condition);
  17092. /**
  17093. * Internal only
  17094. * @hidden
  17095. */
  17096. _prepare(): void;
  17097. /**
  17098. * Gets the trigger parameters
  17099. * @returns the trigger parameters
  17100. */
  17101. getTriggerParameter(): any;
  17102. /**
  17103. * Internal only - executes current action event
  17104. * @hidden
  17105. */
  17106. _executeCurrent(evt?: ActionEvent): void;
  17107. /**
  17108. * Execute placeholder for child classes
  17109. * @param evt optional action event
  17110. */
  17111. execute(evt?: ActionEvent): void;
  17112. /**
  17113. * Skips to next active action
  17114. */
  17115. skipToNextActiveAction(): void;
  17116. /**
  17117. * Adds action to chain of actions, may be a DoNothingAction
  17118. * @param action defines the next action to execute
  17119. * @returns The action passed in
  17120. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17121. */
  17122. then(action: Action): Action;
  17123. /**
  17124. * Internal only
  17125. * @hidden
  17126. */
  17127. _getProperty(propertyPath: string): string;
  17128. /**
  17129. * Internal only
  17130. * @hidden
  17131. */
  17132. _getEffectiveTarget(target: any, propertyPath: string): any;
  17133. /**
  17134. * Serialize placeholder for child classes
  17135. * @param parent of child
  17136. * @returns the serialized object
  17137. */
  17138. serialize(parent: any): any;
  17139. /**
  17140. * Internal only called by serialize
  17141. * @hidden
  17142. */
  17143. protected _serialize(serializedAction: any, parent?: any): any;
  17144. /**
  17145. * Internal only
  17146. * @hidden
  17147. */
  17148. static _SerializeValueAsString: (value: any) => string;
  17149. /**
  17150. * Internal only
  17151. * @hidden
  17152. */
  17153. static _GetTargetProperty: (target: Node | Scene) => {
  17154. name: string;
  17155. targetType: string;
  17156. value: string;
  17157. };
  17158. }
  17159. }
  17160. declare module BABYLON {
  17161. /**
  17162. * A Condition applied to an Action
  17163. */
  17164. export class Condition {
  17165. /**
  17166. * Internal only - manager for action
  17167. * @hidden
  17168. */
  17169. _actionManager: ActionManager;
  17170. /**
  17171. * Internal only
  17172. * @hidden
  17173. */
  17174. _evaluationId: number;
  17175. /**
  17176. * Internal only
  17177. * @hidden
  17178. */
  17179. _currentResult: boolean;
  17180. /**
  17181. * Creates a new Condition
  17182. * @param actionManager the manager of the action the condition is applied to
  17183. */
  17184. constructor(actionManager: ActionManager);
  17185. /**
  17186. * Check if the current condition is valid
  17187. * @returns a boolean
  17188. */
  17189. isValid(): boolean;
  17190. /**
  17191. * Internal only
  17192. * @hidden
  17193. */
  17194. _getProperty(propertyPath: string): string;
  17195. /**
  17196. * Internal only
  17197. * @hidden
  17198. */
  17199. _getEffectiveTarget(target: any, propertyPath: string): any;
  17200. /**
  17201. * Serialize placeholder for child classes
  17202. * @returns the serialized object
  17203. */
  17204. serialize(): any;
  17205. /**
  17206. * Internal only
  17207. * @hidden
  17208. */
  17209. protected _serialize(serializedCondition: any): any;
  17210. }
  17211. /**
  17212. * Defines specific conditional operators as extensions of Condition
  17213. */
  17214. export class ValueCondition extends Condition {
  17215. /** path to specify the property of the target the conditional operator uses */
  17216. propertyPath: string;
  17217. /** the value compared by the conditional operator against the current value of the property */
  17218. value: any;
  17219. /** the conditional operator, default ValueCondition.IsEqual */
  17220. operator: number;
  17221. /**
  17222. * Internal only
  17223. * @hidden
  17224. */
  17225. private static _IsEqual;
  17226. /**
  17227. * Internal only
  17228. * @hidden
  17229. */
  17230. private static _IsDifferent;
  17231. /**
  17232. * Internal only
  17233. * @hidden
  17234. */
  17235. private static _IsGreater;
  17236. /**
  17237. * Internal only
  17238. * @hidden
  17239. */
  17240. private static _IsLesser;
  17241. /**
  17242. * returns the number for IsEqual
  17243. */
  17244. static get IsEqual(): number;
  17245. /**
  17246. * Returns the number for IsDifferent
  17247. */
  17248. static get IsDifferent(): number;
  17249. /**
  17250. * Returns the number for IsGreater
  17251. */
  17252. static get IsGreater(): number;
  17253. /**
  17254. * Returns the number for IsLesser
  17255. */
  17256. static get IsLesser(): number;
  17257. /**
  17258. * Internal only The action manager for the condition
  17259. * @hidden
  17260. */
  17261. _actionManager: ActionManager;
  17262. /**
  17263. * Internal only
  17264. * @hidden
  17265. */
  17266. private _target;
  17267. /**
  17268. * Internal only
  17269. * @hidden
  17270. */
  17271. private _effectiveTarget;
  17272. /**
  17273. * Internal only
  17274. * @hidden
  17275. */
  17276. private _property;
  17277. /**
  17278. * Creates a new ValueCondition
  17279. * @param actionManager manager for the action the condition applies to
  17280. * @param target for the action
  17281. * @param propertyPath path to specify the property of the target the conditional operator uses
  17282. * @param value the value compared by the conditional operator against the current value of the property
  17283. * @param operator the conditional operator, default ValueCondition.IsEqual
  17284. */
  17285. constructor(actionManager: ActionManager, target: any,
  17286. /** path to specify the property of the target the conditional operator uses */
  17287. propertyPath: string,
  17288. /** the value compared by the conditional operator against the current value of the property */
  17289. value: any,
  17290. /** the conditional operator, default ValueCondition.IsEqual */
  17291. operator?: number);
  17292. /**
  17293. * Compares the given value with the property value for the specified conditional operator
  17294. * @returns the result of the comparison
  17295. */
  17296. isValid(): boolean;
  17297. /**
  17298. * Serialize the ValueCondition into a JSON compatible object
  17299. * @returns serialization object
  17300. */
  17301. serialize(): any;
  17302. /**
  17303. * Gets the name of the conditional operator for the ValueCondition
  17304. * @param operator the conditional operator
  17305. * @returns the name
  17306. */
  17307. static GetOperatorName(operator: number): string;
  17308. }
  17309. /**
  17310. * Defines a predicate condition as an extension of Condition
  17311. */
  17312. export class PredicateCondition extends Condition {
  17313. /** defines the predicate function used to validate the condition */
  17314. predicate: () => boolean;
  17315. /**
  17316. * Internal only - manager for action
  17317. * @hidden
  17318. */
  17319. _actionManager: ActionManager;
  17320. /**
  17321. * Creates a new PredicateCondition
  17322. * @param actionManager manager for the action the condition applies to
  17323. * @param predicate defines the predicate function used to validate the condition
  17324. */
  17325. constructor(actionManager: ActionManager,
  17326. /** defines the predicate function used to validate the condition */
  17327. predicate: () => boolean);
  17328. /**
  17329. * @returns the validity of the predicate condition
  17330. */
  17331. isValid(): boolean;
  17332. }
  17333. /**
  17334. * Defines a state condition as an extension of Condition
  17335. */
  17336. export class StateCondition extends Condition {
  17337. /** Value to compare with target state */
  17338. value: string;
  17339. /**
  17340. * Internal only - manager for action
  17341. * @hidden
  17342. */
  17343. _actionManager: ActionManager;
  17344. /**
  17345. * Internal only
  17346. * @hidden
  17347. */
  17348. private _target;
  17349. /**
  17350. * Creates a new StateCondition
  17351. * @param actionManager manager for the action the condition applies to
  17352. * @param target of the condition
  17353. * @param value to compare with target state
  17354. */
  17355. constructor(actionManager: ActionManager, target: any,
  17356. /** Value to compare with target state */
  17357. value: string);
  17358. /**
  17359. * Gets a boolean indicating if the current condition is met
  17360. * @returns the validity of the state
  17361. */
  17362. isValid(): boolean;
  17363. /**
  17364. * Serialize the StateCondition into a JSON compatible object
  17365. * @returns serialization object
  17366. */
  17367. serialize(): any;
  17368. }
  17369. }
  17370. declare module BABYLON {
  17371. /**
  17372. * This defines an action responsible to toggle a boolean once triggered.
  17373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17374. */
  17375. export class SwitchBooleanAction extends Action {
  17376. /**
  17377. * The path to the boolean property in the target object
  17378. */
  17379. propertyPath: string;
  17380. private _target;
  17381. private _effectiveTarget;
  17382. private _property;
  17383. /**
  17384. * Instantiate the action
  17385. * @param triggerOptions defines the trigger options
  17386. * @param target defines the object containing the boolean
  17387. * @param propertyPath defines the path to the boolean property in the target object
  17388. * @param condition defines the trigger related conditions
  17389. */
  17390. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17391. /** @hidden */
  17392. _prepare(): void;
  17393. /**
  17394. * Execute the action toggle the boolean value.
  17395. */
  17396. execute(): void;
  17397. /**
  17398. * Serializes the actions and its related information.
  17399. * @param parent defines the object to serialize in
  17400. * @returns the serialized object
  17401. */
  17402. serialize(parent: any): any;
  17403. }
  17404. /**
  17405. * This defines an action responsible to set a the state field of the target
  17406. * to a desired value once triggered.
  17407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17408. */
  17409. export class SetStateAction extends Action {
  17410. /**
  17411. * The value to store in the state field.
  17412. */
  17413. value: string;
  17414. private _target;
  17415. /**
  17416. * Instantiate the action
  17417. * @param triggerOptions defines the trigger options
  17418. * @param target defines the object containing the state property
  17419. * @param value defines the value to store in the state field
  17420. * @param condition defines the trigger related conditions
  17421. */
  17422. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17423. /**
  17424. * Execute the action and store the value on the target state property.
  17425. */
  17426. execute(): void;
  17427. /**
  17428. * Serializes the actions and its related information.
  17429. * @param parent defines the object to serialize in
  17430. * @returns the serialized object
  17431. */
  17432. serialize(parent: any): any;
  17433. }
  17434. /**
  17435. * This defines an action responsible to set a property of the target
  17436. * to a desired value once triggered.
  17437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17438. */
  17439. export class SetValueAction extends Action {
  17440. /**
  17441. * The path of the property to set in the target.
  17442. */
  17443. propertyPath: string;
  17444. /**
  17445. * The value to set in the property
  17446. */
  17447. value: any;
  17448. private _target;
  17449. private _effectiveTarget;
  17450. private _property;
  17451. /**
  17452. * Instantiate the action
  17453. * @param triggerOptions defines the trigger options
  17454. * @param target defines the object containing the property
  17455. * @param propertyPath defines the path of the property to set in the target
  17456. * @param value defines the value to set in the property
  17457. * @param condition defines the trigger related conditions
  17458. */
  17459. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17460. /** @hidden */
  17461. _prepare(): void;
  17462. /**
  17463. * Execute the action and set the targetted property to the desired value.
  17464. */
  17465. execute(): void;
  17466. /**
  17467. * Serializes the actions and its related information.
  17468. * @param parent defines the object to serialize in
  17469. * @returns the serialized object
  17470. */
  17471. serialize(parent: any): any;
  17472. }
  17473. /**
  17474. * This defines an action responsible to increment the target value
  17475. * to a desired value once triggered.
  17476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17477. */
  17478. export class IncrementValueAction extends Action {
  17479. /**
  17480. * The path of the property to increment in the target.
  17481. */
  17482. propertyPath: string;
  17483. /**
  17484. * The value we should increment the property by.
  17485. */
  17486. value: any;
  17487. private _target;
  17488. private _effectiveTarget;
  17489. private _property;
  17490. /**
  17491. * Instantiate the action
  17492. * @param triggerOptions defines the trigger options
  17493. * @param target defines the object containing the property
  17494. * @param propertyPath defines the path of the property to increment in the target
  17495. * @param value defines the value value we should increment the property by
  17496. * @param condition defines the trigger related conditions
  17497. */
  17498. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17499. /** @hidden */
  17500. _prepare(): void;
  17501. /**
  17502. * Execute the action and increment the target of the value amount.
  17503. */
  17504. execute(): void;
  17505. /**
  17506. * Serializes the actions and its related information.
  17507. * @param parent defines the object to serialize in
  17508. * @returns the serialized object
  17509. */
  17510. serialize(parent: any): any;
  17511. }
  17512. /**
  17513. * This defines an action responsible to start an animation once triggered.
  17514. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17515. */
  17516. export class PlayAnimationAction extends Action {
  17517. /**
  17518. * Where the animation should start (animation frame)
  17519. */
  17520. from: number;
  17521. /**
  17522. * Where the animation should stop (animation frame)
  17523. */
  17524. to: number;
  17525. /**
  17526. * Define if the animation should loop or stop after the first play.
  17527. */
  17528. loop?: boolean;
  17529. private _target;
  17530. /**
  17531. * Instantiate the action
  17532. * @param triggerOptions defines the trigger options
  17533. * @param target defines the target animation or animation name
  17534. * @param from defines from where the animation should start (animation frame)
  17535. * @param end defines where the animation should stop (animation frame)
  17536. * @param loop defines if the animation should loop or stop after the first play
  17537. * @param condition defines the trigger related conditions
  17538. */
  17539. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17540. /** @hidden */
  17541. _prepare(): void;
  17542. /**
  17543. * Execute the action and play the animation.
  17544. */
  17545. execute(): void;
  17546. /**
  17547. * Serializes the actions and its related information.
  17548. * @param parent defines the object to serialize in
  17549. * @returns the serialized object
  17550. */
  17551. serialize(parent: any): any;
  17552. }
  17553. /**
  17554. * This defines an action responsible to stop an animation once triggered.
  17555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17556. */
  17557. export class StopAnimationAction extends Action {
  17558. private _target;
  17559. /**
  17560. * Instantiate the action
  17561. * @param triggerOptions defines the trigger options
  17562. * @param target defines the target animation or animation name
  17563. * @param condition defines the trigger related conditions
  17564. */
  17565. constructor(triggerOptions: any, target: any, condition?: Condition);
  17566. /** @hidden */
  17567. _prepare(): void;
  17568. /**
  17569. * Execute the action and stop the animation.
  17570. */
  17571. execute(): void;
  17572. /**
  17573. * Serializes the actions and its related information.
  17574. * @param parent defines the object to serialize in
  17575. * @returns the serialized object
  17576. */
  17577. serialize(parent: any): any;
  17578. }
  17579. /**
  17580. * This defines an action responsible that does nothing once triggered.
  17581. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17582. */
  17583. export class DoNothingAction extends Action {
  17584. /**
  17585. * Instantiate the action
  17586. * @param triggerOptions defines the trigger options
  17587. * @param condition defines the trigger related conditions
  17588. */
  17589. constructor(triggerOptions?: any, condition?: Condition);
  17590. /**
  17591. * Execute the action and do nothing.
  17592. */
  17593. execute(): void;
  17594. /**
  17595. * Serializes the actions and its related information.
  17596. * @param parent defines the object to serialize in
  17597. * @returns the serialized object
  17598. */
  17599. serialize(parent: any): any;
  17600. }
  17601. /**
  17602. * This defines an action responsible to trigger several actions once triggered.
  17603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17604. */
  17605. export class CombineAction extends Action {
  17606. /**
  17607. * The list of aggregated animations to run.
  17608. */
  17609. children: Action[];
  17610. /**
  17611. * Instantiate the action
  17612. * @param triggerOptions defines the trigger options
  17613. * @param children defines the list of aggregated animations to run
  17614. * @param condition defines the trigger related conditions
  17615. */
  17616. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17617. /** @hidden */
  17618. _prepare(): void;
  17619. /**
  17620. * Execute the action and executes all the aggregated actions.
  17621. */
  17622. execute(evt: ActionEvent): void;
  17623. /**
  17624. * Serializes the actions and its related information.
  17625. * @param parent defines the object to serialize in
  17626. * @returns the serialized object
  17627. */
  17628. serialize(parent: any): any;
  17629. }
  17630. /**
  17631. * This defines an action responsible to run code (external event) once triggered.
  17632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17633. */
  17634. export class ExecuteCodeAction extends Action {
  17635. /**
  17636. * The callback function to run.
  17637. */
  17638. func: (evt: ActionEvent) => void;
  17639. /**
  17640. * Instantiate the action
  17641. * @param triggerOptions defines the trigger options
  17642. * @param func defines the callback function to run
  17643. * @param condition defines the trigger related conditions
  17644. */
  17645. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17646. /**
  17647. * Execute the action and run the attached code.
  17648. */
  17649. execute(evt: ActionEvent): void;
  17650. }
  17651. /**
  17652. * This defines an action responsible to set the parent property of the target once triggered.
  17653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17654. */
  17655. export class SetParentAction extends Action {
  17656. private _parent;
  17657. private _target;
  17658. /**
  17659. * Instantiate the action
  17660. * @param triggerOptions defines the trigger options
  17661. * @param target defines the target containing the parent property
  17662. * @param parent defines from where the animation should start (animation frame)
  17663. * @param condition defines the trigger related conditions
  17664. */
  17665. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17666. /** @hidden */
  17667. _prepare(): void;
  17668. /**
  17669. * Execute the action and set the parent property.
  17670. */
  17671. execute(): void;
  17672. /**
  17673. * Serializes the actions and its related information.
  17674. * @param parent defines the object to serialize in
  17675. * @returns the serialized object
  17676. */
  17677. serialize(parent: any): any;
  17678. }
  17679. }
  17680. declare module BABYLON {
  17681. /**
  17682. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17683. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17685. */
  17686. export class ActionManager extends AbstractActionManager {
  17687. /**
  17688. * Nothing
  17689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17690. */
  17691. static readonly NothingTrigger: number;
  17692. /**
  17693. * On pick
  17694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17695. */
  17696. static readonly OnPickTrigger: number;
  17697. /**
  17698. * On left pick
  17699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17700. */
  17701. static readonly OnLeftPickTrigger: number;
  17702. /**
  17703. * On right pick
  17704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17705. */
  17706. static readonly OnRightPickTrigger: number;
  17707. /**
  17708. * On center pick
  17709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17710. */
  17711. static readonly OnCenterPickTrigger: number;
  17712. /**
  17713. * On pick down
  17714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17715. */
  17716. static readonly OnPickDownTrigger: number;
  17717. /**
  17718. * On double pick
  17719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17720. */
  17721. static readonly OnDoublePickTrigger: number;
  17722. /**
  17723. * On pick up
  17724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17725. */
  17726. static readonly OnPickUpTrigger: number;
  17727. /**
  17728. * On pick out.
  17729. * This trigger will only be raised if you also declared a OnPickDown
  17730. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17731. */
  17732. static readonly OnPickOutTrigger: number;
  17733. /**
  17734. * On long press
  17735. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17736. */
  17737. static readonly OnLongPressTrigger: number;
  17738. /**
  17739. * On pointer over
  17740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17741. */
  17742. static readonly OnPointerOverTrigger: number;
  17743. /**
  17744. * On pointer out
  17745. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17746. */
  17747. static readonly OnPointerOutTrigger: number;
  17748. /**
  17749. * On every frame
  17750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17751. */
  17752. static readonly OnEveryFrameTrigger: number;
  17753. /**
  17754. * On intersection enter
  17755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17756. */
  17757. static readonly OnIntersectionEnterTrigger: number;
  17758. /**
  17759. * On intersection exit
  17760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17761. */
  17762. static readonly OnIntersectionExitTrigger: number;
  17763. /**
  17764. * On key down
  17765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17766. */
  17767. static readonly OnKeyDownTrigger: number;
  17768. /**
  17769. * On key up
  17770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17771. */
  17772. static readonly OnKeyUpTrigger: number;
  17773. private _scene;
  17774. /**
  17775. * Creates a new action manager
  17776. * @param scene defines the hosting scene
  17777. */
  17778. constructor(scene: Scene);
  17779. /**
  17780. * Releases all associated resources
  17781. */
  17782. dispose(): void;
  17783. /**
  17784. * Gets hosting scene
  17785. * @returns the hosting scene
  17786. */
  17787. getScene(): Scene;
  17788. /**
  17789. * Does this action manager handles actions of any of the given triggers
  17790. * @param triggers defines the triggers to be tested
  17791. * @return a boolean indicating whether one (or more) of the triggers is handled
  17792. */
  17793. hasSpecificTriggers(triggers: number[]): boolean;
  17794. /**
  17795. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17796. * speed.
  17797. * @param triggerA defines the trigger to be tested
  17798. * @param triggerB defines the trigger to be tested
  17799. * @return a boolean indicating whether one (or more) of the triggers is handled
  17800. */
  17801. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17802. /**
  17803. * Does this action manager handles actions of a given trigger
  17804. * @param trigger defines the trigger to be tested
  17805. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17806. * @return whether the trigger is handled
  17807. */
  17808. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17809. /**
  17810. * Does this action manager has pointer triggers
  17811. */
  17812. get hasPointerTriggers(): boolean;
  17813. /**
  17814. * Does this action manager has pick triggers
  17815. */
  17816. get hasPickTriggers(): boolean;
  17817. /**
  17818. * Registers an action to this action manager
  17819. * @param action defines the action to be registered
  17820. * @return the action amended (prepared) after registration
  17821. */
  17822. registerAction(action: IAction): Nullable<IAction>;
  17823. /**
  17824. * Unregisters an action to this action manager
  17825. * @param action defines the action to be unregistered
  17826. * @return a boolean indicating whether the action has been unregistered
  17827. */
  17828. unregisterAction(action: IAction): Boolean;
  17829. /**
  17830. * Process a specific trigger
  17831. * @param trigger defines the trigger to process
  17832. * @param evt defines the event details to be processed
  17833. */
  17834. processTrigger(trigger: number, evt?: IActionEvent): void;
  17835. /** @hidden */
  17836. _getEffectiveTarget(target: any, propertyPath: string): any;
  17837. /** @hidden */
  17838. _getProperty(propertyPath: string): string;
  17839. /**
  17840. * Serialize this manager to a JSON object
  17841. * @param name defines the property name to store this manager
  17842. * @returns a JSON representation of this manager
  17843. */
  17844. serialize(name: string): any;
  17845. /**
  17846. * Creates a new ActionManager from a JSON data
  17847. * @param parsedActions defines the JSON data to read from
  17848. * @param object defines the hosting mesh
  17849. * @param scene defines the hosting scene
  17850. */
  17851. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17852. /**
  17853. * Get a trigger name by index
  17854. * @param trigger defines the trigger index
  17855. * @returns a trigger name
  17856. */
  17857. static GetTriggerName(trigger: number): string;
  17858. }
  17859. }
  17860. declare module BABYLON {
  17861. /**
  17862. * Class used to represent a sprite
  17863. * @see http://doc.babylonjs.com/babylon101/sprites
  17864. */
  17865. export class Sprite {
  17866. /** defines the name */
  17867. name: string;
  17868. /** Gets or sets the current world position */
  17869. position: Vector3;
  17870. /** Gets or sets the main color */
  17871. color: Color4;
  17872. /** Gets or sets the width */
  17873. width: number;
  17874. /** Gets or sets the height */
  17875. height: number;
  17876. /** Gets or sets rotation angle */
  17877. angle: number;
  17878. /** Gets or sets the cell index in the sprite sheet */
  17879. cellIndex: number;
  17880. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17881. cellRef: string;
  17882. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17883. invertU: number;
  17884. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17885. invertV: number;
  17886. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17887. disposeWhenFinishedAnimating: boolean;
  17888. /** Gets the list of attached animations */
  17889. animations: Animation[];
  17890. /** Gets or sets a boolean indicating if the sprite can be picked */
  17891. isPickable: boolean;
  17892. /**
  17893. * Gets or sets the associated action manager
  17894. */
  17895. actionManager: Nullable<ActionManager>;
  17896. private _animationStarted;
  17897. private _loopAnimation;
  17898. private _fromIndex;
  17899. private _toIndex;
  17900. private _delay;
  17901. private _direction;
  17902. private _manager;
  17903. private _time;
  17904. private _onAnimationEnd;
  17905. /**
  17906. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17907. */
  17908. isVisible: boolean;
  17909. /**
  17910. * Gets or sets the sprite size
  17911. */
  17912. get size(): number;
  17913. set size(value: number);
  17914. /**
  17915. * Creates a new Sprite
  17916. * @param name defines the name
  17917. * @param manager defines the manager
  17918. */
  17919. constructor(
  17920. /** defines the name */
  17921. name: string, manager: ISpriteManager);
  17922. /**
  17923. * Starts an animation
  17924. * @param from defines the initial key
  17925. * @param to defines the end key
  17926. * @param loop defines if the animation must loop
  17927. * @param delay defines the start delay (in ms)
  17928. * @param onAnimationEnd defines a callback to call when animation ends
  17929. */
  17930. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17931. /** Stops current animation (if any) */
  17932. stopAnimation(): void;
  17933. /** @hidden */
  17934. _animate(deltaTime: number): void;
  17935. /** Release associated resources */
  17936. dispose(): void;
  17937. }
  17938. }
  17939. declare module BABYLON {
  17940. /**
  17941. * Information about the result of picking within a scene
  17942. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17943. */
  17944. export class PickingInfo {
  17945. /** @hidden */
  17946. _pickingUnavailable: boolean;
  17947. /**
  17948. * If the pick collided with an object
  17949. */
  17950. hit: boolean;
  17951. /**
  17952. * Distance away where the pick collided
  17953. */
  17954. distance: number;
  17955. /**
  17956. * The location of pick collision
  17957. */
  17958. pickedPoint: Nullable<Vector3>;
  17959. /**
  17960. * The mesh corresponding the the pick collision
  17961. */
  17962. pickedMesh: Nullable<AbstractMesh>;
  17963. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17964. bu: number;
  17965. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17966. bv: number;
  17967. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17968. faceId: number;
  17969. /** Id of the the submesh that was picked */
  17970. subMeshId: number;
  17971. /** If a sprite was picked, this will be the sprite the pick collided with */
  17972. pickedSprite: Nullable<Sprite>;
  17973. /**
  17974. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17975. */
  17976. originMesh: Nullable<AbstractMesh>;
  17977. /**
  17978. * The ray that was used to perform the picking.
  17979. */
  17980. ray: Nullable<Ray>;
  17981. /**
  17982. * Gets the normal correspodning to the face the pick collided with
  17983. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  17984. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  17985. * @returns The normal correspodning to the face the pick collided with
  17986. */
  17987. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  17988. /**
  17989. * Gets the texture coordinates of where the pick occured
  17990. * @returns the vector containing the coordnates of the texture
  17991. */
  17992. getTextureCoordinates(): Nullable<Vector2>;
  17993. }
  17994. }
  17995. declare module BABYLON {
  17996. /**
  17997. * Gather the list of pointer event types as constants.
  17998. */
  17999. export class PointerEventTypes {
  18000. /**
  18001. * 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.
  18002. */
  18003. static readonly POINTERDOWN: number;
  18004. /**
  18005. * The pointerup event is fired when a pointer is no longer active.
  18006. */
  18007. static readonly POINTERUP: number;
  18008. /**
  18009. * The pointermove event is fired when a pointer changes coordinates.
  18010. */
  18011. static readonly POINTERMOVE: number;
  18012. /**
  18013. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18014. */
  18015. static readonly POINTERWHEEL: number;
  18016. /**
  18017. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18018. */
  18019. static readonly POINTERPICK: number;
  18020. /**
  18021. * The pointertap event is fired when a the object has been touched and released without drag.
  18022. */
  18023. static readonly POINTERTAP: number;
  18024. /**
  18025. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18026. */
  18027. static readonly POINTERDOUBLETAP: number;
  18028. }
  18029. /**
  18030. * Base class of pointer info types.
  18031. */
  18032. export class PointerInfoBase {
  18033. /**
  18034. * Defines the type of event (PointerEventTypes)
  18035. */
  18036. type: number;
  18037. /**
  18038. * Defines the related dom event
  18039. */
  18040. event: PointerEvent | MouseWheelEvent;
  18041. /**
  18042. * Instantiates the base class of pointers info.
  18043. * @param type Defines the type of event (PointerEventTypes)
  18044. * @param event Defines the related dom event
  18045. */
  18046. constructor(
  18047. /**
  18048. * Defines the type of event (PointerEventTypes)
  18049. */
  18050. type: number,
  18051. /**
  18052. * Defines the related dom event
  18053. */
  18054. event: PointerEvent | MouseWheelEvent);
  18055. }
  18056. /**
  18057. * This class is used to store pointer related info for the onPrePointerObservable event.
  18058. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18059. */
  18060. export class PointerInfoPre extends PointerInfoBase {
  18061. /**
  18062. * Ray from a pointer if availible (eg. 6dof controller)
  18063. */
  18064. ray: Nullable<Ray>;
  18065. /**
  18066. * Defines the local position of the pointer on the canvas.
  18067. */
  18068. localPosition: Vector2;
  18069. /**
  18070. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18071. */
  18072. skipOnPointerObservable: boolean;
  18073. /**
  18074. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18075. * @param type Defines the type of event (PointerEventTypes)
  18076. * @param event Defines the related dom event
  18077. * @param localX Defines the local x coordinates of the pointer when the event occured
  18078. * @param localY Defines the local y coordinates of the pointer when the event occured
  18079. */
  18080. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18081. }
  18082. /**
  18083. * This type contains all the data related to a pointer event in Babylon.js.
  18084. * 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.
  18085. */
  18086. export class PointerInfo extends PointerInfoBase {
  18087. /**
  18088. * Defines the picking info associated to the info (if any)\
  18089. */
  18090. pickInfo: Nullable<PickingInfo>;
  18091. /**
  18092. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18093. * @param type Defines the type of event (PointerEventTypes)
  18094. * @param event Defines the related dom event
  18095. * @param pickInfo Defines the picking info associated to the info (if any)\
  18096. */
  18097. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18098. /**
  18099. * Defines the picking info associated to the info (if any)\
  18100. */
  18101. pickInfo: Nullable<PickingInfo>);
  18102. }
  18103. /**
  18104. * Data relating to a touch event on the screen.
  18105. */
  18106. export interface PointerTouch {
  18107. /**
  18108. * X coordinate of touch.
  18109. */
  18110. x: number;
  18111. /**
  18112. * Y coordinate of touch.
  18113. */
  18114. y: number;
  18115. /**
  18116. * Id of touch. Unique for each finger.
  18117. */
  18118. pointerId: number;
  18119. /**
  18120. * Event type passed from DOM.
  18121. */
  18122. type: any;
  18123. }
  18124. }
  18125. declare module BABYLON {
  18126. /**
  18127. * Manage the mouse inputs to control the movement of a free camera.
  18128. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18129. */
  18130. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18131. /**
  18132. * Define if touch is enabled in the mouse input
  18133. */
  18134. touchEnabled: boolean;
  18135. /**
  18136. * Defines the camera the input is attached to.
  18137. */
  18138. camera: FreeCamera;
  18139. /**
  18140. * Defines the buttons associated with the input to handle camera move.
  18141. */
  18142. buttons: number[];
  18143. /**
  18144. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18145. */
  18146. angularSensibility: number;
  18147. private _pointerInput;
  18148. private _onMouseMove;
  18149. private _observer;
  18150. private previousPosition;
  18151. /**
  18152. * Observable for when a pointer move event occurs containing the move offset
  18153. */
  18154. onPointerMovedObservable: Observable<{
  18155. offsetX: number;
  18156. offsetY: number;
  18157. }>;
  18158. /**
  18159. * @hidden
  18160. * If the camera should be rotated automatically based on pointer movement
  18161. */
  18162. _allowCameraRotation: boolean;
  18163. /**
  18164. * Manage the mouse inputs to control the movement of a free camera.
  18165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18166. * @param touchEnabled Defines if touch is enabled or not
  18167. */
  18168. constructor(
  18169. /**
  18170. * Define if touch is enabled in the mouse input
  18171. */
  18172. touchEnabled?: boolean);
  18173. /**
  18174. * Attach the input controls to a specific dom element to get the input from.
  18175. * @param element Defines the element the controls should be listened from
  18176. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18177. */
  18178. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18179. /**
  18180. * Called on JS contextmenu event.
  18181. * Override this method to provide functionality.
  18182. */
  18183. protected onContextMenu(evt: PointerEvent): void;
  18184. /**
  18185. * Detach the current controls from the specified dom element.
  18186. * @param element Defines the element to stop listening the inputs from
  18187. */
  18188. detachControl(element: Nullable<HTMLElement>): void;
  18189. /**
  18190. * Gets the class name of the current intput.
  18191. * @returns the class name
  18192. */
  18193. getClassName(): string;
  18194. /**
  18195. * Get the friendly name associated with the input class.
  18196. * @returns the input friendly name
  18197. */
  18198. getSimpleName(): string;
  18199. }
  18200. }
  18201. declare module BABYLON {
  18202. /**
  18203. * Manage the touch inputs to control the movement of a free camera.
  18204. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18205. */
  18206. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18207. /**
  18208. * Defines the camera the input is attached to.
  18209. */
  18210. camera: FreeCamera;
  18211. /**
  18212. * Defines the touch sensibility for rotation.
  18213. * The higher the faster.
  18214. */
  18215. touchAngularSensibility: number;
  18216. /**
  18217. * Defines the touch sensibility for move.
  18218. * The higher the faster.
  18219. */
  18220. touchMoveSensibility: number;
  18221. private _offsetX;
  18222. private _offsetY;
  18223. private _pointerPressed;
  18224. private _pointerInput;
  18225. private _observer;
  18226. private _onLostFocus;
  18227. /**
  18228. * Attach the input controls to a specific dom element to get the input from.
  18229. * @param element Defines the element the controls should be listened from
  18230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18231. */
  18232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18233. /**
  18234. * Detach the current controls from the specified dom element.
  18235. * @param element Defines the element to stop listening the inputs from
  18236. */
  18237. detachControl(element: Nullable<HTMLElement>): void;
  18238. /**
  18239. * Update the current camera state depending on the inputs that have been used this frame.
  18240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18241. */
  18242. checkInputs(): void;
  18243. /**
  18244. * Gets the class name of the current intput.
  18245. * @returns the class name
  18246. */
  18247. getClassName(): string;
  18248. /**
  18249. * Get the friendly name associated with the input class.
  18250. * @returns the input friendly name
  18251. */
  18252. getSimpleName(): string;
  18253. }
  18254. }
  18255. declare module BABYLON {
  18256. /**
  18257. * Default Inputs manager for the FreeCamera.
  18258. * It groups all the default supported inputs for ease of use.
  18259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18260. */
  18261. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18262. /**
  18263. * @hidden
  18264. */
  18265. _mouseInput: Nullable<FreeCameraMouseInput>;
  18266. /**
  18267. * Instantiates a new FreeCameraInputsManager.
  18268. * @param camera Defines the camera the inputs belong to
  18269. */
  18270. constructor(camera: FreeCamera);
  18271. /**
  18272. * Add keyboard input support to the input manager.
  18273. * @returns the current input manager
  18274. */
  18275. addKeyboard(): FreeCameraInputsManager;
  18276. /**
  18277. * Add mouse input support to the input manager.
  18278. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18279. * @returns the current input manager
  18280. */
  18281. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18282. /**
  18283. * Removes the mouse input support from the manager
  18284. * @returns the current input manager
  18285. */
  18286. removeMouse(): FreeCameraInputsManager;
  18287. /**
  18288. * Add touch input support to the input manager.
  18289. * @returns the current input manager
  18290. */
  18291. addTouch(): FreeCameraInputsManager;
  18292. /**
  18293. * Remove all attached input methods from a camera
  18294. */
  18295. clear(): void;
  18296. }
  18297. }
  18298. declare module BABYLON {
  18299. /**
  18300. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18301. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18302. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18303. */
  18304. export class FreeCamera extends TargetCamera {
  18305. /**
  18306. * Define the collision ellipsoid of the camera.
  18307. * This is helpful to simulate a camera body like the player body around the camera
  18308. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18309. */
  18310. ellipsoid: Vector3;
  18311. /**
  18312. * Define an offset for the position of the ellipsoid around the camera.
  18313. * This can be helpful to determine the center of the body near the gravity center of the body
  18314. * instead of its head.
  18315. */
  18316. ellipsoidOffset: Vector3;
  18317. /**
  18318. * Enable or disable collisions of the camera with the rest of the scene objects.
  18319. */
  18320. checkCollisions: boolean;
  18321. /**
  18322. * Enable or disable gravity on the camera.
  18323. */
  18324. applyGravity: boolean;
  18325. /**
  18326. * Define the input manager associated to the camera.
  18327. */
  18328. inputs: FreeCameraInputsManager;
  18329. /**
  18330. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18331. * Higher values reduce sensitivity.
  18332. */
  18333. get angularSensibility(): number;
  18334. /**
  18335. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18336. * Higher values reduce sensitivity.
  18337. */
  18338. set angularSensibility(value: number);
  18339. /**
  18340. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18341. */
  18342. get keysUp(): number[];
  18343. set keysUp(value: number[]);
  18344. /**
  18345. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18346. */
  18347. get keysDown(): number[];
  18348. set keysDown(value: number[]);
  18349. /**
  18350. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18351. */
  18352. get keysLeft(): number[];
  18353. set keysLeft(value: number[]);
  18354. /**
  18355. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18356. */
  18357. get keysRight(): number[];
  18358. set keysRight(value: number[]);
  18359. /**
  18360. * Event raised when the camera collide with a mesh in the scene.
  18361. */
  18362. onCollide: (collidedMesh: AbstractMesh) => void;
  18363. private _collider;
  18364. private _needMoveForGravity;
  18365. private _oldPosition;
  18366. private _diffPosition;
  18367. private _newPosition;
  18368. /** @hidden */
  18369. _localDirection: Vector3;
  18370. /** @hidden */
  18371. _transformedDirection: Vector3;
  18372. /**
  18373. * Instantiates a Free Camera.
  18374. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18375. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18376. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18377. * @param name Define the name of the camera in the scene
  18378. * @param position Define the start position of the camera in the scene
  18379. * @param scene Define the scene the camera belongs to
  18380. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18381. */
  18382. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18383. /**
  18384. * Attached controls to the current camera.
  18385. * @param element Defines the element the controls should be listened from
  18386. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18387. */
  18388. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18389. /**
  18390. * Detach the current controls from the camera.
  18391. * The camera will stop reacting to inputs.
  18392. * @param element Defines the element to stop listening the inputs from
  18393. */
  18394. detachControl(element: HTMLElement): void;
  18395. private _collisionMask;
  18396. /**
  18397. * Define a collision mask to limit the list of object the camera can collide with
  18398. */
  18399. get collisionMask(): number;
  18400. set collisionMask(mask: number);
  18401. /** @hidden */
  18402. _collideWithWorld(displacement: Vector3): void;
  18403. private _onCollisionPositionChange;
  18404. /** @hidden */
  18405. _checkInputs(): void;
  18406. /** @hidden */
  18407. _decideIfNeedsToMove(): boolean;
  18408. /** @hidden */
  18409. _updatePosition(): void;
  18410. /**
  18411. * Destroy the camera and release the current resources hold by it.
  18412. */
  18413. dispose(): void;
  18414. /**
  18415. * Gets the current object class name.
  18416. * @return the class name
  18417. */
  18418. getClassName(): string;
  18419. }
  18420. }
  18421. declare module BABYLON {
  18422. /**
  18423. * Represents a gamepad control stick position
  18424. */
  18425. export class StickValues {
  18426. /**
  18427. * The x component of the control stick
  18428. */
  18429. x: number;
  18430. /**
  18431. * The y component of the control stick
  18432. */
  18433. y: number;
  18434. /**
  18435. * Initializes the gamepad x and y control stick values
  18436. * @param x The x component of the gamepad control stick value
  18437. * @param y The y component of the gamepad control stick value
  18438. */
  18439. constructor(
  18440. /**
  18441. * The x component of the control stick
  18442. */
  18443. x: number,
  18444. /**
  18445. * The y component of the control stick
  18446. */
  18447. y: number);
  18448. }
  18449. /**
  18450. * An interface which manages callbacks for gamepad button changes
  18451. */
  18452. export interface GamepadButtonChanges {
  18453. /**
  18454. * Called when a gamepad has been changed
  18455. */
  18456. changed: boolean;
  18457. /**
  18458. * Called when a gamepad press event has been triggered
  18459. */
  18460. pressChanged: boolean;
  18461. /**
  18462. * Called when a touch event has been triggered
  18463. */
  18464. touchChanged: boolean;
  18465. /**
  18466. * Called when a value has changed
  18467. */
  18468. valueChanged: boolean;
  18469. }
  18470. /**
  18471. * Represents a gamepad
  18472. */
  18473. export class Gamepad {
  18474. /**
  18475. * The id of the gamepad
  18476. */
  18477. id: string;
  18478. /**
  18479. * The index of the gamepad
  18480. */
  18481. index: number;
  18482. /**
  18483. * The browser gamepad
  18484. */
  18485. browserGamepad: any;
  18486. /**
  18487. * Specifies what type of gamepad this represents
  18488. */
  18489. type: number;
  18490. private _leftStick;
  18491. private _rightStick;
  18492. /** @hidden */
  18493. _isConnected: boolean;
  18494. private _leftStickAxisX;
  18495. private _leftStickAxisY;
  18496. private _rightStickAxisX;
  18497. private _rightStickAxisY;
  18498. /**
  18499. * Triggered when the left control stick has been changed
  18500. */
  18501. private _onleftstickchanged;
  18502. /**
  18503. * Triggered when the right control stick has been changed
  18504. */
  18505. private _onrightstickchanged;
  18506. /**
  18507. * Represents a gamepad controller
  18508. */
  18509. static GAMEPAD: number;
  18510. /**
  18511. * Represents a generic controller
  18512. */
  18513. static GENERIC: number;
  18514. /**
  18515. * Represents an XBox controller
  18516. */
  18517. static XBOX: number;
  18518. /**
  18519. * Represents a pose-enabled controller
  18520. */
  18521. static POSE_ENABLED: number;
  18522. /**
  18523. * Represents an Dual Shock controller
  18524. */
  18525. static DUALSHOCK: number;
  18526. /**
  18527. * Specifies whether the left control stick should be Y-inverted
  18528. */
  18529. protected _invertLeftStickY: boolean;
  18530. /**
  18531. * Specifies if the gamepad has been connected
  18532. */
  18533. get isConnected(): boolean;
  18534. /**
  18535. * Initializes the gamepad
  18536. * @param id The id of the gamepad
  18537. * @param index The index of the gamepad
  18538. * @param browserGamepad The browser gamepad
  18539. * @param leftStickX The x component of the left joystick
  18540. * @param leftStickY The y component of the left joystick
  18541. * @param rightStickX The x component of the right joystick
  18542. * @param rightStickY The y component of the right joystick
  18543. */
  18544. constructor(
  18545. /**
  18546. * The id of the gamepad
  18547. */
  18548. id: string,
  18549. /**
  18550. * The index of the gamepad
  18551. */
  18552. index: number,
  18553. /**
  18554. * The browser gamepad
  18555. */
  18556. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18557. /**
  18558. * Callback triggered when the left joystick has changed
  18559. * @param callback
  18560. */
  18561. onleftstickchanged(callback: (values: StickValues) => void): void;
  18562. /**
  18563. * Callback triggered when the right joystick has changed
  18564. * @param callback
  18565. */
  18566. onrightstickchanged(callback: (values: StickValues) => void): void;
  18567. /**
  18568. * Gets the left joystick
  18569. */
  18570. get leftStick(): StickValues;
  18571. /**
  18572. * Sets the left joystick values
  18573. */
  18574. set leftStick(newValues: StickValues);
  18575. /**
  18576. * Gets the right joystick
  18577. */
  18578. get rightStick(): StickValues;
  18579. /**
  18580. * Sets the right joystick value
  18581. */
  18582. set rightStick(newValues: StickValues);
  18583. /**
  18584. * Updates the gamepad joystick positions
  18585. */
  18586. update(): void;
  18587. /**
  18588. * Disposes the gamepad
  18589. */
  18590. dispose(): void;
  18591. }
  18592. /**
  18593. * Represents a generic gamepad
  18594. */
  18595. export class GenericPad extends Gamepad {
  18596. private _buttons;
  18597. private _onbuttondown;
  18598. private _onbuttonup;
  18599. /**
  18600. * Observable triggered when a button has been pressed
  18601. */
  18602. onButtonDownObservable: Observable<number>;
  18603. /**
  18604. * Observable triggered when a button has been released
  18605. */
  18606. onButtonUpObservable: Observable<number>;
  18607. /**
  18608. * Callback triggered when a button has been pressed
  18609. * @param callback Called when a button has been pressed
  18610. */
  18611. onbuttondown(callback: (buttonPressed: number) => void): void;
  18612. /**
  18613. * Callback triggered when a button has been released
  18614. * @param callback Called when a button has been released
  18615. */
  18616. onbuttonup(callback: (buttonReleased: number) => void): void;
  18617. /**
  18618. * Initializes the generic gamepad
  18619. * @param id The id of the generic gamepad
  18620. * @param index The index of the generic gamepad
  18621. * @param browserGamepad The browser gamepad
  18622. */
  18623. constructor(id: string, index: number, browserGamepad: any);
  18624. private _setButtonValue;
  18625. /**
  18626. * Updates the generic gamepad
  18627. */
  18628. update(): void;
  18629. /**
  18630. * Disposes the generic gamepad
  18631. */
  18632. dispose(): void;
  18633. }
  18634. }
  18635. declare module BABYLON {
  18636. /**
  18637. * Defines the types of pose enabled controllers that are supported
  18638. */
  18639. export enum PoseEnabledControllerType {
  18640. /**
  18641. * HTC Vive
  18642. */
  18643. VIVE = 0,
  18644. /**
  18645. * Oculus Rift
  18646. */
  18647. OCULUS = 1,
  18648. /**
  18649. * Windows mixed reality
  18650. */
  18651. WINDOWS = 2,
  18652. /**
  18653. * Samsung gear VR
  18654. */
  18655. GEAR_VR = 3,
  18656. /**
  18657. * Google Daydream
  18658. */
  18659. DAYDREAM = 4,
  18660. /**
  18661. * Generic
  18662. */
  18663. GENERIC = 5
  18664. }
  18665. /**
  18666. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18667. */
  18668. export interface MutableGamepadButton {
  18669. /**
  18670. * Value of the button/trigger
  18671. */
  18672. value: number;
  18673. /**
  18674. * If the button/trigger is currently touched
  18675. */
  18676. touched: boolean;
  18677. /**
  18678. * If the button/trigger is currently pressed
  18679. */
  18680. pressed: boolean;
  18681. }
  18682. /**
  18683. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18684. * @hidden
  18685. */
  18686. export interface ExtendedGamepadButton extends GamepadButton {
  18687. /**
  18688. * If the button/trigger is currently pressed
  18689. */
  18690. readonly pressed: boolean;
  18691. /**
  18692. * If the button/trigger is currently touched
  18693. */
  18694. readonly touched: boolean;
  18695. /**
  18696. * Value of the button/trigger
  18697. */
  18698. readonly value: number;
  18699. }
  18700. /** @hidden */
  18701. export interface _GamePadFactory {
  18702. /**
  18703. * Returns whether or not the current gamepad can be created for this type of controller.
  18704. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18705. * @returns true if it can be created, otherwise false
  18706. */
  18707. canCreate(gamepadInfo: any): boolean;
  18708. /**
  18709. * Creates a new instance of the Gamepad.
  18710. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18711. * @returns the new gamepad instance
  18712. */
  18713. create(gamepadInfo: any): Gamepad;
  18714. }
  18715. /**
  18716. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18717. */
  18718. export class PoseEnabledControllerHelper {
  18719. /** @hidden */
  18720. static _ControllerFactories: _GamePadFactory[];
  18721. /** @hidden */
  18722. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18723. /**
  18724. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18725. * @param vrGamepad the gamepad to initialized
  18726. * @returns a vr controller of the type the gamepad identified as
  18727. */
  18728. static InitiateController(vrGamepad: any): Gamepad;
  18729. }
  18730. /**
  18731. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18732. */
  18733. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18734. /**
  18735. * If the controller is used in a webXR session
  18736. */
  18737. isXR: boolean;
  18738. private _deviceRoomPosition;
  18739. private _deviceRoomRotationQuaternion;
  18740. /**
  18741. * The device position in babylon space
  18742. */
  18743. devicePosition: Vector3;
  18744. /**
  18745. * The device rotation in babylon space
  18746. */
  18747. deviceRotationQuaternion: Quaternion;
  18748. /**
  18749. * The scale factor of the device in babylon space
  18750. */
  18751. deviceScaleFactor: number;
  18752. /**
  18753. * (Likely devicePosition should be used instead) The device position in its room space
  18754. */
  18755. position: Vector3;
  18756. /**
  18757. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18758. */
  18759. rotationQuaternion: Quaternion;
  18760. /**
  18761. * The type of controller (Eg. Windows mixed reality)
  18762. */
  18763. controllerType: PoseEnabledControllerType;
  18764. protected _calculatedPosition: Vector3;
  18765. private _calculatedRotation;
  18766. /**
  18767. * The raw pose from the device
  18768. */
  18769. rawPose: DevicePose;
  18770. private _trackPosition;
  18771. private _maxRotationDistFromHeadset;
  18772. private _draggedRoomRotation;
  18773. /**
  18774. * @hidden
  18775. */
  18776. _disableTrackPosition(fixedPosition: Vector3): void;
  18777. /**
  18778. * Internal, the mesh attached to the controller
  18779. * @hidden
  18780. */
  18781. _mesh: Nullable<AbstractMesh>;
  18782. private _poseControlledCamera;
  18783. private _leftHandSystemQuaternion;
  18784. /**
  18785. * Internal, matrix used to convert room space to babylon space
  18786. * @hidden
  18787. */
  18788. _deviceToWorld: Matrix;
  18789. /**
  18790. * Node to be used when casting a ray from the controller
  18791. * @hidden
  18792. */
  18793. _pointingPoseNode: Nullable<TransformNode>;
  18794. /**
  18795. * Name of the child mesh that can be used to cast a ray from the controller
  18796. */
  18797. static readonly POINTING_POSE: string;
  18798. /**
  18799. * Creates a new PoseEnabledController from a gamepad
  18800. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18801. */
  18802. constructor(browserGamepad: any);
  18803. private _workingMatrix;
  18804. /**
  18805. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18806. */
  18807. update(): void;
  18808. /**
  18809. * Updates only the pose device and mesh without doing any button event checking
  18810. */
  18811. protected _updatePoseAndMesh(): void;
  18812. /**
  18813. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18814. * @param poseData raw pose fromthe device
  18815. */
  18816. updateFromDevice(poseData: DevicePose): void;
  18817. /**
  18818. * @hidden
  18819. */
  18820. _meshAttachedObservable: Observable<AbstractMesh>;
  18821. /**
  18822. * Attaches a mesh to the controller
  18823. * @param mesh the mesh to be attached
  18824. */
  18825. attachToMesh(mesh: AbstractMesh): void;
  18826. /**
  18827. * Attaches the controllers mesh to a camera
  18828. * @param camera the camera the mesh should be attached to
  18829. */
  18830. attachToPoseControlledCamera(camera: TargetCamera): void;
  18831. /**
  18832. * Disposes of the controller
  18833. */
  18834. dispose(): void;
  18835. /**
  18836. * The mesh that is attached to the controller
  18837. */
  18838. get mesh(): Nullable<AbstractMesh>;
  18839. /**
  18840. * Gets the ray of the controller in the direction the controller is pointing
  18841. * @param length the length the resulting ray should be
  18842. * @returns a ray in the direction the controller is pointing
  18843. */
  18844. getForwardRay(length?: number): Ray;
  18845. }
  18846. }
  18847. declare module BABYLON {
  18848. /**
  18849. * Defines the WebVRController object that represents controllers tracked in 3D space
  18850. */
  18851. export abstract class WebVRController extends PoseEnabledController {
  18852. /**
  18853. * Internal, the default controller model for the controller
  18854. */
  18855. protected _defaultModel: Nullable<AbstractMesh>;
  18856. /**
  18857. * Fired when the trigger state has changed
  18858. */
  18859. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18860. /**
  18861. * Fired when the main button state has changed
  18862. */
  18863. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18864. /**
  18865. * Fired when the secondary button state has changed
  18866. */
  18867. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18868. /**
  18869. * Fired when the pad state has changed
  18870. */
  18871. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18872. /**
  18873. * Fired when controllers stick values have changed
  18874. */
  18875. onPadValuesChangedObservable: Observable<StickValues>;
  18876. /**
  18877. * Array of button availible on the controller
  18878. */
  18879. protected _buttons: Array<MutableGamepadButton>;
  18880. private _onButtonStateChange;
  18881. /**
  18882. * Fired when a controller button's state has changed
  18883. * @param callback the callback containing the button that was modified
  18884. */
  18885. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18886. /**
  18887. * X and Y axis corresponding to the controllers joystick
  18888. */
  18889. pad: StickValues;
  18890. /**
  18891. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18892. */
  18893. hand: string;
  18894. /**
  18895. * The default controller model for the controller
  18896. */
  18897. get defaultModel(): Nullable<AbstractMesh>;
  18898. /**
  18899. * Creates a new WebVRController from a gamepad
  18900. * @param vrGamepad the gamepad that the WebVRController should be created from
  18901. */
  18902. constructor(vrGamepad: any);
  18903. /**
  18904. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18905. */
  18906. update(): void;
  18907. /**
  18908. * Function to be called when a button is modified
  18909. */
  18910. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18911. /**
  18912. * Loads a mesh and attaches it to the controller
  18913. * @param scene the scene the mesh should be added to
  18914. * @param meshLoaded callback for when the mesh has been loaded
  18915. */
  18916. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18917. private _setButtonValue;
  18918. private _changes;
  18919. private _checkChanges;
  18920. /**
  18921. * Disposes of th webVRCOntroller
  18922. */
  18923. dispose(): void;
  18924. }
  18925. }
  18926. declare module BABYLON {
  18927. /**
  18928. * The HemisphericLight simulates the ambient environment light,
  18929. * so the passed direction is the light reflection direction, not the incoming direction.
  18930. */
  18931. export class HemisphericLight extends Light {
  18932. /**
  18933. * The groundColor is the light in the opposite direction to the one specified during creation.
  18934. * 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.
  18935. */
  18936. groundColor: Color3;
  18937. /**
  18938. * The light reflection direction, not the incoming direction.
  18939. */
  18940. direction: Vector3;
  18941. /**
  18942. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18943. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18944. * The HemisphericLight can't cast shadows.
  18945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18946. * @param name The friendly name of the light
  18947. * @param direction The direction of the light reflection
  18948. * @param scene The scene the light belongs to
  18949. */
  18950. constructor(name: string, direction: Vector3, scene: Scene);
  18951. protected _buildUniformLayout(): void;
  18952. /**
  18953. * Returns the string "HemisphericLight".
  18954. * @return The class name
  18955. */
  18956. getClassName(): string;
  18957. /**
  18958. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18959. * Returns the updated direction.
  18960. * @param target The target the direction should point to
  18961. * @return The computed direction
  18962. */
  18963. setDirectionToTarget(target: Vector3): Vector3;
  18964. /**
  18965. * Returns the shadow generator associated to the light.
  18966. * @returns Always null for hemispheric lights because it does not support shadows.
  18967. */
  18968. getShadowGenerator(): Nullable<IShadowGenerator>;
  18969. /**
  18970. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18971. * @param effect The effect to update
  18972. * @param lightIndex The index of the light in the effect to update
  18973. * @returns The hemispheric light
  18974. */
  18975. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18976. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18977. /**
  18978. * Computes the world matrix of the node
  18979. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18980. * @param useWasUpdatedFlag defines a reserved property
  18981. * @returns the world matrix
  18982. */
  18983. computeWorldMatrix(): Matrix;
  18984. /**
  18985. * Returns the integer 3.
  18986. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18987. */
  18988. getTypeID(): number;
  18989. /**
  18990. * Prepares the list of defines specific to the light type.
  18991. * @param defines the list of defines
  18992. * @param lightIndex defines the index of the light for the effect
  18993. */
  18994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18995. }
  18996. }
  18997. declare module BABYLON {
  18998. /** @hidden */
  18999. export var vrMultiviewToSingleviewPixelShader: {
  19000. name: string;
  19001. shader: string;
  19002. };
  19003. }
  19004. declare module BABYLON {
  19005. /**
  19006. * Renders to multiple views with a single draw call
  19007. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19008. */
  19009. export class MultiviewRenderTarget extends RenderTargetTexture {
  19010. /**
  19011. * Creates a multiview render target
  19012. * @param scene scene used with the render target
  19013. * @param size the size of the render target (used for each view)
  19014. */
  19015. constructor(scene: Scene, size?: number | {
  19016. width: number;
  19017. height: number;
  19018. } | {
  19019. ratio: number;
  19020. });
  19021. /**
  19022. * @hidden
  19023. * @param faceIndex the face index, if its a cube texture
  19024. */
  19025. _bindFrameBuffer(faceIndex?: number): void;
  19026. /**
  19027. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19028. * @returns the view count
  19029. */
  19030. getViewCount(): number;
  19031. }
  19032. }
  19033. declare module BABYLON {
  19034. /**
  19035. * Represents a camera frustum
  19036. */
  19037. export class Frustum {
  19038. /**
  19039. * Gets the planes representing the frustum
  19040. * @param transform matrix to be applied to the returned planes
  19041. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19042. */
  19043. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19044. /**
  19045. * Gets the near frustum plane transformed by the transform matrix
  19046. * @param transform transformation matrix to be applied to the resulting frustum plane
  19047. * @param frustumPlane the resuling frustum plane
  19048. */
  19049. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19050. /**
  19051. * Gets the far frustum plane transformed by the transform matrix
  19052. * @param transform transformation matrix to be applied to the resulting frustum plane
  19053. * @param frustumPlane the resuling frustum plane
  19054. */
  19055. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19056. /**
  19057. * Gets the left frustum plane transformed by the transform matrix
  19058. * @param transform transformation matrix to be applied to the resulting frustum plane
  19059. * @param frustumPlane the resuling frustum plane
  19060. */
  19061. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19062. /**
  19063. * Gets the right frustum plane transformed by the transform matrix
  19064. * @param transform transformation matrix to be applied to the resulting frustum plane
  19065. * @param frustumPlane the resuling frustum plane
  19066. */
  19067. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19068. /**
  19069. * Gets the top frustum plane transformed by the transform matrix
  19070. * @param transform transformation matrix to be applied to the resulting frustum plane
  19071. * @param frustumPlane the resuling frustum plane
  19072. */
  19073. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19074. /**
  19075. * Gets the bottom frustum plane transformed by the transform matrix
  19076. * @param transform transformation matrix to be applied to the resulting frustum plane
  19077. * @param frustumPlane the resuling frustum plane
  19078. */
  19079. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19080. /**
  19081. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19082. * @param transform transformation matrix to be applied to the resulting frustum planes
  19083. * @param frustumPlanes the resuling frustum planes
  19084. */
  19085. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19086. }
  19087. }
  19088. declare module BABYLON {
  19089. interface Engine {
  19090. /**
  19091. * Creates a new multiview render target
  19092. * @param width defines the width of the texture
  19093. * @param height defines the height of the texture
  19094. * @returns the created multiview texture
  19095. */
  19096. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19097. /**
  19098. * Binds a multiview framebuffer to be drawn to
  19099. * @param multiviewTexture texture to bind
  19100. */
  19101. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19102. }
  19103. interface Camera {
  19104. /**
  19105. * @hidden
  19106. * 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)
  19107. */
  19108. _useMultiviewToSingleView: boolean;
  19109. /**
  19110. * @hidden
  19111. * 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)
  19112. */
  19113. _multiviewTexture: Nullable<RenderTargetTexture>;
  19114. /**
  19115. * @hidden
  19116. * ensures the multiview texture of the camera exists and has the specified width/height
  19117. * @param width height to set on the multiview texture
  19118. * @param height width to set on the multiview texture
  19119. */
  19120. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19121. }
  19122. interface Scene {
  19123. /** @hidden */
  19124. _transformMatrixR: Matrix;
  19125. /** @hidden */
  19126. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19127. /** @hidden */
  19128. _createMultiviewUbo(): void;
  19129. /** @hidden */
  19130. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19131. /** @hidden */
  19132. _renderMultiviewToSingleView(camera: Camera): void;
  19133. }
  19134. }
  19135. declare module BABYLON {
  19136. /**
  19137. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19138. * This will not be used for webXR as it supports displaying texture arrays directly
  19139. */
  19140. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19141. /**
  19142. * Initializes a VRMultiviewToSingleview
  19143. * @param name name of the post process
  19144. * @param camera camera to be applied to
  19145. * @param scaleFactor scaling factor to the size of the output texture
  19146. */
  19147. constructor(name: string, camera: Camera, scaleFactor: number);
  19148. }
  19149. }
  19150. declare module BABYLON {
  19151. /**
  19152. * Interface used to define additional presentation attributes
  19153. */
  19154. export interface IVRPresentationAttributes {
  19155. /**
  19156. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19157. */
  19158. highRefreshRate: boolean;
  19159. /**
  19160. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19161. */
  19162. foveationLevel: number;
  19163. }
  19164. interface Engine {
  19165. /** @hidden */
  19166. _vrDisplay: any;
  19167. /** @hidden */
  19168. _vrSupported: boolean;
  19169. /** @hidden */
  19170. _oldSize: Size;
  19171. /** @hidden */
  19172. _oldHardwareScaleFactor: number;
  19173. /** @hidden */
  19174. _vrExclusivePointerMode: boolean;
  19175. /** @hidden */
  19176. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19177. /** @hidden */
  19178. _onVRDisplayPointerRestricted: () => void;
  19179. /** @hidden */
  19180. _onVRDisplayPointerUnrestricted: () => void;
  19181. /** @hidden */
  19182. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19183. /** @hidden */
  19184. _onVrDisplayDisconnect: Nullable<() => void>;
  19185. /** @hidden */
  19186. _onVrDisplayPresentChange: Nullable<() => void>;
  19187. /**
  19188. * Observable signaled when VR display mode changes
  19189. */
  19190. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19191. /**
  19192. * Observable signaled when VR request present is complete
  19193. */
  19194. onVRRequestPresentComplete: Observable<boolean>;
  19195. /**
  19196. * Observable signaled when VR request present starts
  19197. */
  19198. onVRRequestPresentStart: Observable<Engine>;
  19199. /**
  19200. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19201. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19202. */
  19203. isInVRExclusivePointerMode: boolean;
  19204. /**
  19205. * Gets a boolean indicating if a webVR device was detected
  19206. * @returns true if a webVR device was detected
  19207. */
  19208. isVRDevicePresent(): boolean;
  19209. /**
  19210. * Gets the current webVR device
  19211. * @returns the current webVR device (or null)
  19212. */
  19213. getVRDevice(): any;
  19214. /**
  19215. * Initializes a webVR display and starts listening to display change events
  19216. * The onVRDisplayChangedObservable will be notified upon these changes
  19217. * @returns A promise containing a VRDisplay and if vr is supported
  19218. */
  19219. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19220. /** @hidden */
  19221. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19222. /**
  19223. * Gets or sets the presentation attributes used to configure VR rendering
  19224. */
  19225. vrPresentationAttributes?: IVRPresentationAttributes;
  19226. /**
  19227. * Call this function to switch to webVR mode
  19228. * Will do nothing if webVR is not supported or if there is no webVR device
  19229. * @param options the webvr options provided to the camera. mainly used for multiview
  19230. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19231. */
  19232. enableVR(options: WebVROptions): void;
  19233. /** @hidden */
  19234. _onVRFullScreenTriggered(): void;
  19235. }
  19236. }
  19237. declare module BABYLON {
  19238. /**
  19239. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19240. * IMPORTANT!! The data is right-hand data.
  19241. * @export
  19242. * @interface DevicePose
  19243. */
  19244. export interface DevicePose {
  19245. /**
  19246. * The position of the device, values in array are [x,y,z].
  19247. */
  19248. readonly position: Nullable<Float32Array>;
  19249. /**
  19250. * The linearVelocity of the device, values in array are [x,y,z].
  19251. */
  19252. readonly linearVelocity: Nullable<Float32Array>;
  19253. /**
  19254. * The linearAcceleration of the device, values in array are [x,y,z].
  19255. */
  19256. readonly linearAcceleration: Nullable<Float32Array>;
  19257. /**
  19258. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19259. */
  19260. readonly orientation: Nullable<Float32Array>;
  19261. /**
  19262. * The angularVelocity of the device, values in array are [x,y,z].
  19263. */
  19264. readonly angularVelocity: Nullable<Float32Array>;
  19265. /**
  19266. * The angularAcceleration of the device, values in array are [x,y,z].
  19267. */
  19268. readonly angularAcceleration: Nullable<Float32Array>;
  19269. }
  19270. /**
  19271. * Interface representing a pose controlled object in Babylon.
  19272. * A pose controlled object has both regular pose values as well as pose values
  19273. * from an external device such as a VR head mounted display
  19274. */
  19275. export interface PoseControlled {
  19276. /**
  19277. * The position of the object in babylon space.
  19278. */
  19279. position: Vector3;
  19280. /**
  19281. * The rotation quaternion of the object in babylon space.
  19282. */
  19283. rotationQuaternion: Quaternion;
  19284. /**
  19285. * The position of the device in babylon space.
  19286. */
  19287. devicePosition?: Vector3;
  19288. /**
  19289. * The rotation quaternion of the device in babylon space.
  19290. */
  19291. deviceRotationQuaternion: Quaternion;
  19292. /**
  19293. * The raw pose coming from the device.
  19294. */
  19295. rawPose: Nullable<DevicePose>;
  19296. /**
  19297. * The scale of the device to be used when translating from device space to babylon space.
  19298. */
  19299. deviceScaleFactor: number;
  19300. /**
  19301. * Updates the poseControlled values based on the input device pose.
  19302. * @param poseData the pose data to update the object with
  19303. */
  19304. updateFromDevice(poseData: DevicePose): void;
  19305. }
  19306. /**
  19307. * Set of options to customize the webVRCamera
  19308. */
  19309. export interface WebVROptions {
  19310. /**
  19311. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19312. */
  19313. trackPosition?: boolean;
  19314. /**
  19315. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19316. */
  19317. positionScale?: number;
  19318. /**
  19319. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19320. */
  19321. displayName?: string;
  19322. /**
  19323. * Should the native controller meshes be initialized. (default: true)
  19324. */
  19325. controllerMeshes?: boolean;
  19326. /**
  19327. * Creating a default HemiLight only on controllers. (default: true)
  19328. */
  19329. defaultLightingOnControllers?: boolean;
  19330. /**
  19331. * If you don't want to use the default VR button of the helper. (default: false)
  19332. */
  19333. useCustomVRButton?: boolean;
  19334. /**
  19335. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19336. */
  19337. customVRButton?: HTMLButtonElement;
  19338. /**
  19339. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19340. */
  19341. rayLength?: number;
  19342. /**
  19343. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19344. */
  19345. defaultHeight?: number;
  19346. /**
  19347. * If multiview should be used if availible (default: false)
  19348. */
  19349. useMultiview?: boolean;
  19350. }
  19351. /**
  19352. * This represents a WebVR camera.
  19353. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19354. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19355. */
  19356. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19357. private webVROptions;
  19358. /**
  19359. * @hidden
  19360. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19361. */
  19362. _vrDevice: any;
  19363. /**
  19364. * The rawPose of the vrDevice.
  19365. */
  19366. rawPose: Nullable<DevicePose>;
  19367. private _onVREnabled;
  19368. private _specsVersion;
  19369. private _attached;
  19370. private _frameData;
  19371. protected _descendants: Array<Node>;
  19372. private _deviceRoomPosition;
  19373. /** @hidden */
  19374. _deviceRoomRotationQuaternion: Quaternion;
  19375. private _standingMatrix;
  19376. /**
  19377. * Represents device position in babylon space.
  19378. */
  19379. devicePosition: Vector3;
  19380. /**
  19381. * Represents device rotation in babylon space.
  19382. */
  19383. deviceRotationQuaternion: Quaternion;
  19384. /**
  19385. * The scale of the device to be used when translating from device space to babylon space.
  19386. */
  19387. deviceScaleFactor: number;
  19388. private _deviceToWorld;
  19389. private _worldToDevice;
  19390. /**
  19391. * References to the webVR controllers for the vrDevice.
  19392. */
  19393. controllers: Array<WebVRController>;
  19394. /**
  19395. * Emits an event when a controller is attached.
  19396. */
  19397. onControllersAttachedObservable: Observable<WebVRController[]>;
  19398. /**
  19399. * Emits an event when a controller's mesh has been loaded;
  19400. */
  19401. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19402. /**
  19403. * Emits an event when the HMD's pose has been updated.
  19404. */
  19405. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19406. private _poseSet;
  19407. /**
  19408. * If the rig cameras be used as parent instead of this camera.
  19409. */
  19410. rigParenting: boolean;
  19411. private _lightOnControllers;
  19412. private _defaultHeight?;
  19413. /**
  19414. * Instantiates a WebVRFreeCamera.
  19415. * @param name The name of the WebVRFreeCamera
  19416. * @param position The starting anchor position for the camera
  19417. * @param scene The scene the camera belongs to
  19418. * @param webVROptions a set of customizable options for the webVRCamera
  19419. */
  19420. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19421. /**
  19422. * Gets the device distance from the ground in meters.
  19423. * @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.
  19424. */
  19425. deviceDistanceToRoomGround(): number;
  19426. /**
  19427. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19428. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19429. */
  19430. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19431. /**
  19432. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19433. * @returns A promise with a boolean set to if the standing matrix is supported.
  19434. */
  19435. useStandingMatrixAsync(): Promise<boolean>;
  19436. /**
  19437. * Disposes the camera
  19438. */
  19439. dispose(): void;
  19440. /**
  19441. * Gets a vrController by name.
  19442. * @param name The name of the controller to retreive
  19443. * @returns the controller matching the name specified or null if not found
  19444. */
  19445. getControllerByName(name: string): Nullable<WebVRController>;
  19446. private _leftController;
  19447. /**
  19448. * The controller corresponding to the users left hand.
  19449. */
  19450. get leftController(): Nullable<WebVRController>;
  19451. private _rightController;
  19452. /**
  19453. * The controller corresponding to the users right hand.
  19454. */
  19455. get rightController(): Nullable<WebVRController>;
  19456. /**
  19457. * Casts a ray forward from the vrCamera's gaze.
  19458. * @param length Length of the ray (default: 100)
  19459. * @returns the ray corresponding to the gaze
  19460. */
  19461. getForwardRay(length?: number): Ray;
  19462. /**
  19463. * @hidden
  19464. * Updates the camera based on device's frame data
  19465. */
  19466. _checkInputs(): void;
  19467. /**
  19468. * Updates the poseControlled values based on the input device pose.
  19469. * @param poseData Pose coming from the device
  19470. */
  19471. updateFromDevice(poseData: DevicePose): void;
  19472. private _htmlElementAttached;
  19473. private _detachIfAttached;
  19474. /**
  19475. * WebVR's attach control will start broadcasting frames to the device.
  19476. * Note that in certain browsers (chrome for example) this function must be called
  19477. * within a user-interaction callback. Example:
  19478. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19479. *
  19480. * @param element html element to attach the vrDevice to
  19481. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19482. */
  19483. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19484. /**
  19485. * Detaches the camera from the html element and disables VR
  19486. *
  19487. * @param element html element to detach from
  19488. */
  19489. detachControl(element: HTMLElement): void;
  19490. /**
  19491. * @returns the name of this class
  19492. */
  19493. getClassName(): string;
  19494. /**
  19495. * Calls resetPose on the vrDisplay
  19496. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19497. */
  19498. resetToCurrentRotation(): void;
  19499. /**
  19500. * @hidden
  19501. * Updates the rig cameras (left and right eye)
  19502. */
  19503. _updateRigCameras(): void;
  19504. private _workingVector;
  19505. private _oneVector;
  19506. private _workingMatrix;
  19507. private updateCacheCalled;
  19508. private _correctPositionIfNotTrackPosition;
  19509. /**
  19510. * @hidden
  19511. * Updates the cached values of the camera
  19512. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19513. */
  19514. _updateCache(ignoreParentClass?: boolean): void;
  19515. /**
  19516. * @hidden
  19517. * Get current device position in babylon world
  19518. */
  19519. _computeDevicePosition(): void;
  19520. /**
  19521. * Updates the current device position and rotation in the babylon world
  19522. */
  19523. update(): void;
  19524. /**
  19525. * @hidden
  19526. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19527. * @returns an identity matrix
  19528. */
  19529. _getViewMatrix(): Matrix;
  19530. private _tmpMatrix;
  19531. /**
  19532. * This function is called by the two RIG cameras.
  19533. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19534. * @hidden
  19535. */
  19536. _getWebVRViewMatrix(): Matrix;
  19537. /** @hidden */
  19538. _getWebVRProjectionMatrix(): Matrix;
  19539. private _onGamepadConnectedObserver;
  19540. private _onGamepadDisconnectedObserver;
  19541. private _updateCacheWhenTrackingDisabledObserver;
  19542. /**
  19543. * Initializes the controllers and their meshes
  19544. */
  19545. initControllers(): void;
  19546. }
  19547. }
  19548. declare module BABYLON {
  19549. /**
  19550. * Size options for a post process
  19551. */
  19552. export type PostProcessOptions = {
  19553. width: number;
  19554. height: number;
  19555. };
  19556. /**
  19557. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19558. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19559. */
  19560. export class PostProcess {
  19561. /** Name of the PostProcess. */
  19562. name: string;
  19563. /**
  19564. * Gets or sets the unique id of the post process
  19565. */
  19566. uniqueId: number;
  19567. /**
  19568. * Width of the texture to apply the post process on
  19569. */
  19570. width: number;
  19571. /**
  19572. * Height of the texture to apply the post process on
  19573. */
  19574. height: number;
  19575. /**
  19576. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19577. * @hidden
  19578. */
  19579. _outputTexture: Nullable<InternalTexture>;
  19580. /**
  19581. * Sampling mode used by the shader
  19582. * See https://doc.babylonjs.com/classes/3.1/texture
  19583. */
  19584. renderTargetSamplingMode: number;
  19585. /**
  19586. * Clear color to use when screen clearing
  19587. */
  19588. clearColor: Color4;
  19589. /**
  19590. * If the buffer needs to be cleared before applying the post process. (default: true)
  19591. * Should be set to false if shader will overwrite all previous pixels.
  19592. */
  19593. autoClear: boolean;
  19594. /**
  19595. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19596. */
  19597. alphaMode: number;
  19598. /**
  19599. * Sets the setAlphaBlendConstants of the babylon engine
  19600. */
  19601. alphaConstants: Color4;
  19602. /**
  19603. * Animations to be used for the post processing
  19604. */
  19605. animations: Animation[];
  19606. /**
  19607. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19608. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19609. */
  19610. enablePixelPerfectMode: boolean;
  19611. /**
  19612. * Force the postprocess to be applied without taking in account viewport
  19613. */
  19614. forceFullscreenViewport: boolean;
  19615. /**
  19616. * List of inspectable custom properties (used by the Inspector)
  19617. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19618. */
  19619. inspectableCustomProperties: IInspectable[];
  19620. /**
  19621. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19622. *
  19623. * | Value | Type | Description |
  19624. * | ----- | ----------------------------------- | ----------- |
  19625. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19626. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19627. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19628. *
  19629. */
  19630. scaleMode: number;
  19631. /**
  19632. * Force textures to be a power of two (default: false)
  19633. */
  19634. alwaysForcePOT: boolean;
  19635. private _samples;
  19636. /**
  19637. * Number of sample textures (default: 1)
  19638. */
  19639. get samples(): number;
  19640. set samples(n: number);
  19641. /**
  19642. * Modify the scale of the post process to be the same as the viewport (default: false)
  19643. */
  19644. adaptScaleToCurrentViewport: boolean;
  19645. private _camera;
  19646. private _scene;
  19647. private _engine;
  19648. private _options;
  19649. private _reusable;
  19650. private _textureType;
  19651. private _textureFormat;
  19652. /**
  19653. * Smart array of input and output textures for the post process.
  19654. * @hidden
  19655. */
  19656. _textures: SmartArray<InternalTexture>;
  19657. /**
  19658. * The index in _textures that corresponds to the output texture.
  19659. * @hidden
  19660. */
  19661. _currentRenderTextureInd: number;
  19662. private _effect;
  19663. private _samplers;
  19664. private _fragmentUrl;
  19665. private _vertexUrl;
  19666. private _parameters;
  19667. private _scaleRatio;
  19668. protected _indexParameters: any;
  19669. private _shareOutputWithPostProcess;
  19670. private _texelSize;
  19671. private _forcedOutputTexture;
  19672. /**
  19673. * Returns the fragment url or shader name used in the post process.
  19674. * @returns the fragment url or name in the shader store.
  19675. */
  19676. getEffectName(): string;
  19677. /**
  19678. * An event triggered when the postprocess is activated.
  19679. */
  19680. onActivateObservable: Observable<Camera>;
  19681. private _onActivateObserver;
  19682. /**
  19683. * A function that is added to the onActivateObservable
  19684. */
  19685. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19686. /**
  19687. * An event triggered when the postprocess changes its size.
  19688. */
  19689. onSizeChangedObservable: Observable<PostProcess>;
  19690. private _onSizeChangedObserver;
  19691. /**
  19692. * A function that is added to the onSizeChangedObservable
  19693. */
  19694. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19695. /**
  19696. * An event triggered when the postprocess applies its effect.
  19697. */
  19698. onApplyObservable: Observable<Effect>;
  19699. private _onApplyObserver;
  19700. /**
  19701. * A function that is added to the onApplyObservable
  19702. */
  19703. set onApply(callback: (effect: Effect) => void);
  19704. /**
  19705. * An event triggered before rendering the postprocess
  19706. */
  19707. onBeforeRenderObservable: Observable<Effect>;
  19708. private _onBeforeRenderObserver;
  19709. /**
  19710. * A function that is added to the onBeforeRenderObservable
  19711. */
  19712. set onBeforeRender(callback: (effect: Effect) => void);
  19713. /**
  19714. * An event triggered after rendering the postprocess
  19715. */
  19716. onAfterRenderObservable: Observable<Effect>;
  19717. private _onAfterRenderObserver;
  19718. /**
  19719. * A function that is added to the onAfterRenderObservable
  19720. */
  19721. set onAfterRender(callback: (efect: Effect) => void);
  19722. /**
  19723. * 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
  19724. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19725. */
  19726. get inputTexture(): InternalTexture;
  19727. set inputTexture(value: InternalTexture);
  19728. /**
  19729. * Gets the camera which post process is applied to.
  19730. * @returns The camera the post process is applied to.
  19731. */
  19732. getCamera(): Camera;
  19733. /**
  19734. * Gets the texel size of the postprocess.
  19735. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19736. */
  19737. get texelSize(): Vector2;
  19738. /**
  19739. * Creates a new instance PostProcess
  19740. * @param name The name of the PostProcess.
  19741. * @param fragmentUrl The url of the fragment shader to be used.
  19742. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19743. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19744. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19745. * @param camera The camera to apply the render pass to.
  19746. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19747. * @param engine The engine which the post process will be applied. (default: current engine)
  19748. * @param reusable If the post process can be reused on the same frame. (default: false)
  19749. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19750. * @param textureType Type of textures used when performing the post process. (default: 0)
  19751. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19752. * @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
  19753. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19754. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19755. */
  19756. constructor(
  19757. /** Name of the PostProcess. */
  19758. 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, textureFormat?: number);
  19759. /**
  19760. * Gets a string idenfifying the name of the class
  19761. * @returns "PostProcess" string
  19762. */
  19763. getClassName(): string;
  19764. /**
  19765. * Gets the engine which this post process belongs to.
  19766. * @returns The engine the post process was enabled with.
  19767. */
  19768. getEngine(): Engine;
  19769. /**
  19770. * The effect that is created when initializing the post process.
  19771. * @returns The created effect corresponding the the postprocess.
  19772. */
  19773. getEffect(): Effect;
  19774. /**
  19775. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19776. * @param postProcess The post process to share the output with.
  19777. * @returns This post process.
  19778. */
  19779. shareOutputWith(postProcess: PostProcess): PostProcess;
  19780. /**
  19781. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19782. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19783. */
  19784. useOwnOutput(): void;
  19785. /**
  19786. * Updates the effect with the current post process compile time values and recompiles the shader.
  19787. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19788. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19789. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19790. * @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
  19791. * @param onCompiled Called when the shader has been compiled.
  19792. * @param onError Called if there is an error when compiling a shader.
  19793. */
  19794. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19795. /**
  19796. * The post process is reusable if it can be used multiple times within one frame.
  19797. * @returns If the post process is reusable
  19798. */
  19799. isReusable(): boolean;
  19800. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19801. markTextureDirty(): void;
  19802. /**
  19803. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19804. * 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.
  19805. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19806. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19807. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19808. * @returns The target texture that was bound to be written to.
  19809. */
  19810. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19811. /**
  19812. * If the post process is supported.
  19813. */
  19814. get isSupported(): boolean;
  19815. /**
  19816. * The aspect ratio of the output texture.
  19817. */
  19818. get aspectRatio(): number;
  19819. /**
  19820. * Get a value indicating if the post-process is ready to be used
  19821. * @returns true if the post-process is ready (shader is compiled)
  19822. */
  19823. isReady(): boolean;
  19824. /**
  19825. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19826. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19827. */
  19828. apply(): Nullable<Effect>;
  19829. private _disposeTextures;
  19830. /**
  19831. * Disposes the post process.
  19832. * @param camera The camera to dispose the post process on.
  19833. */
  19834. dispose(camera?: Camera): void;
  19835. }
  19836. }
  19837. declare module BABYLON {
  19838. /** @hidden */
  19839. export var kernelBlurVaryingDeclaration: {
  19840. name: string;
  19841. shader: string;
  19842. };
  19843. }
  19844. declare module BABYLON {
  19845. /** @hidden */
  19846. export var kernelBlurFragment: {
  19847. name: string;
  19848. shader: string;
  19849. };
  19850. }
  19851. declare module BABYLON {
  19852. /** @hidden */
  19853. export var kernelBlurFragment2: {
  19854. name: string;
  19855. shader: string;
  19856. };
  19857. }
  19858. declare module BABYLON {
  19859. /** @hidden */
  19860. export var kernelBlurPixelShader: {
  19861. name: string;
  19862. shader: string;
  19863. };
  19864. }
  19865. declare module BABYLON {
  19866. /** @hidden */
  19867. export var kernelBlurVertex: {
  19868. name: string;
  19869. shader: string;
  19870. };
  19871. }
  19872. declare module BABYLON {
  19873. /** @hidden */
  19874. export var kernelBlurVertexShader: {
  19875. name: string;
  19876. shader: string;
  19877. };
  19878. }
  19879. declare module BABYLON {
  19880. /**
  19881. * The Blur Post Process which blurs an image based on a kernel and direction.
  19882. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19883. */
  19884. export class BlurPostProcess extends PostProcess {
  19885. /** The direction in which to blur the image. */
  19886. direction: Vector2;
  19887. private blockCompilation;
  19888. protected _kernel: number;
  19889. protected _idealKernel: number;
  19890. protected _packedFloat: boolean;
  19891. private _staticDefines;
  19892. /**
  19893. * Sets the length in pixels of the blur sample region
  19894. */
  19895. set kernel(v: number);
  19896. /**
  19897. * Gets the length in pixels of the blur sample region
  19898. */
  19899. get kernel(): number;
  19900. /**
  19901. * Sets wether or not the blur needs to unpack/repack floats
  19902. */
  19903. set packedFloat(v: boolean);
  19904. /**
  19905. * Gets wether or not the blur is unpacking/repacking floats
  19906. */
  19907. get packedFloat(): boolean;
  19908. /**
  19909. * Creates a new instance BlurPostProcess
  19910. * @param name The name of the effect.
  19911. * @param direction The direction in which to blur the image.
  19912. * @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.
  19913. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19914. * @param camera The camera to apply the render pass to.
  19915. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19916. * @param engine The engine which the post process will be applied. (default: current engine)
  19917. * @param reusable If the post process can be reused on the same frame. (default: false)
  19918. * @param textureType Type of textures used when performing the post process. (default: 0)
  19919. * @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)
  19920. */
  19921. constructor(name: string,
  19922. /** The direction in which to blur the image. */
  19923. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19924. /**
  19925. * Updates the effect with the current post process compile time values and recompiles the shader.
  19926. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19927. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19928. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19929. * @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
  19930. * @param onCompiled Called when the shader has been compiled.
  19931. * @param onError Called if there is an error when compiling a shader.
  19932. */
  19933. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19934. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19935. /**
  19936. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19937. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19938. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19939. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19940. * The gaps between physical kernels are compensated for in the weighting of the samples
  19941. * @param idealKernel Ideal blur kernel.
  19942. * @return Nearest best kernel.
  19943. */
  19944. protected _nearestBestKernel(idealKernel: number): number;
  19945. /**
  19946. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19947. * @param x The point on the Gaussian distribution to sample.
  19948. * @return the value of the Gaussian function at x.
  19949. */
  19950. protected _gaussianWeight(x: number): number;
  19951. /**
  19952. * Generates a string that can be used as a floating point number in GLSL.
  19953. * @param x Value to print.
  19954. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19955. * @return GLSL float string.
  19956. */
  19957. protected _glslFloat(x: number, decimalFigures?: number): string;
  19958. }
  19959. }
  19960. declare module BABYLON {
  19961. /**
  19962. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19963. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19964. * You can then easily use it as a reflectionTexture on a flat surface.
  19965. * In case the surface is not a plane, please consider relying on reflection probes.
  19966. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19967. */
  19968. export class MirrorTexture extends RenderTargetTexture {
  19969. private scene;
  19970. /**
  19971. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19972. * 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.
  19973. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19974. */
  19975. mirrorPlane: Plane;
  19976. /**
  19977. * Define the blur ratio used to blur the reflection if needed.
  19978. */
  19979. set blurRatio(value: number);
  19980. get blurRatio(): number;
  19981. /**
  19982. * Define the adaptive blur kernel used to blur the reflection if needed.
  19983. * This will autocompute the closest best match for the `blurKernel`
  19984. */
  19985. set adaptiveBlurKernel(value: number);
  19986. /**
  19987. * Define the blur kernel used to blur the reflection if needed.
  19988. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19989. */
  19990. set blurKernel(value: number);
  19991. /**
  19992. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  19993. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19994. */
  19995. set blurKernelX(value: number);
  19996. get blurKernelX(): number;
  19997. /**
  19998. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  19999. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20000. */
  20001. set blurKernelY(value: number);
  20002. get blurKernelY(): number;
  20003. private _autoComputeBlurKernel;
  20004. protected _onRatioRescale(): void;
  20005. private _updateGammaSpace;
  20006. private _imageProcessingConfigChangeObserver;
  20007. private _transformMatrix;
  20008. private _mirrorMatrix;
  20009. private _savedViewMatrix;
  20010. private _blurX;
  20011. private _blurY;
  20012. private _adaptiveBlurKernel;
  20013. private _blurKernelX;
  20014. private _blurKernelY;
  20015. private _blurRatio;
  20016. /**
  20017. * Instantiates a Mirror Texture.
  20018. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20019. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20020. * You can then easily use it as a reflectionTexture on a flat surface.
  20021. * In case the surface is not a plane, please consider relying on reflection probes.
  20022. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20023. * @param name
  20024. * @param size
  20025. * @param scene
  20026. * @param generateMipMaps
  20027. * @param type
  20028. * @param samplingMode
  20029. * @param generateDepthBuffer
  20030. */
  20031. constructor(name: string, size: number | {
  20032. width: number;
  20033. height: number;
  20034. } | {
  20035. ratio: number;
  20036. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20037. private _preparePostProcesses;
  20038. /**
  20039. * Clone the mirror texture.
  20040. * @returns the cloned texture
  20041. */
  20042. clone(): MirrorTexture;
  20043. /**
  20044. * Serialize the texture to a JSON representation you could use in Parse later on
  20045. * @returns the serialized JSON representation
  20046. */
  20047. serialize(): any;
  20048. /**
  20049. * Dispose the texture and release its associated resources.
  20050. */
  20051. dispose(): void;
  20052. }
  20053. }
  20054. declare module BABYLON {
  20055. /**
  20056. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20057. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20058. */
  20059. export class Texture extends BaseTexture {
  20060. /**
  20061. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20062. */
  20063. static SerializeBuffers: boolean;
  20064. /** @hidden */
  20065. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20066. /** @hidden */
  20067. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20068. /** @hidden */
  20069. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20070. /** nearest is mag = nearest and min = nearest and mip = linear */
  20071. static readonly NEAREST_SAMPLINGMODE: number;
  20072. /** nearest is mag = nearest and min = nearest and mip = linear */
  20073. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20074. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20075. static readonly BILINEAR_SAMPLINGMODE: number;
  20076. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20077. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20078. /** Trilinear is mag = linear and min = linear and mip = linear */
  20079. static readonly TRILINEAR_SAMPLINGMODE: number;
  20080. /** Trilinear is mag = linear and min = linear and mip = linear */
  20081. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20082. /** mag = nearest and min = nearest and mip = nearest */
  20083. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20084. /** mag = nearest and min = linear and mip = nearest */
  20085. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20086. /** mag = nearest and min = linear and mip = linear */
  20087. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20088. /** mag = nearest and min = linear and mip = none */
  20089. static readonly NEAREST_LINEAR: number;
  20090. /** mag = nearest and min = nearest and mip = none */
  20091. static readonly NEAREST_NEAREST: number;
  20092. /** mag = linear and min = nearest and mip = nearest */
  20093. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20094. /** mag = linear and min = nearest and mip = linear */
  20095. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20096. /** mag = linear and min = linear and mip = none */
  20097. static readonly LINEAR_LINEAR: number;
  20098. /** mag = linear and min = nearest and mip = none */
  20099. static readonly LINEAR_NEAREST: number;
  20100. /** Explicit coordinates mode */
  20101. static readonly EXPLICIT_MODE: number;
  20102. /** Spherical coordinates mode */
  20103. static readonly SPHERICAL_MODE: number;
  20104. /** Planar coordinates mode */
  20105. static readonly PLANAR_MODE: number;
  20106. /** Cubic coordinates mode */
  20107. static readonly CUBIC_MODE: number;
  20108. /** Projection coordinates mode */
  20109. static readonly PROJECTION_MODE: number;
  20110. /** Inverse Cubic coordinates mode */
  20111. static readonly SKYBOX_MODE: number;
  20112. /** Inverse Cubic coordinates mode */
  20113. static readonly INVCUBIC_MODE: number;
  20114. /** Equirectangular coordinates mode */
  20115. static readonly EQUIRECTANGULAR_MODE: number;
  20116. /** Equirectangular Fixed coordinates mode */
  20117. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20118. /** Equirectangular Fixed Mirrored coordinates mode */
  20119. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20120. /** Texture is not repeating outside of 0..1 UVs */
  20121. static readonly CLAMP_ADDRESSMODE: number;
  20122. /** Texture is repeating outside of 0..1 UVs */
  20123. static readonly WRAP_ADDRESSMODE: number;
  20124. /** Texture is repeating and mirrored */
  20125. static readonly MIRROR_ADDRESSMODE: number;
  20126. /**
  20127. * 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
  20128. */
  20129. static UseSerializedUrlIfAny: boolean;
  20130. /**
  20131. * Define the url of the texture.
  20132. */
  20133. url: Nullable<string>;
  20134. /**
  20135. * Define an offset on the texture to offset the u coordinates of the UVs
  20136. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20137. */
  20138. uOffset: number;
  20139. /**
  20140. * Define an offset on the texture to offset the v coordinates of the UVs
  20141. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20142. */
  20143. vOffset: number;
  20144. /**
  20145. * Define an offset on the texture to scale the u coordinates of the UVs
  20146. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20147. */
  20148. uScale: number;
  20149. /**
  20150. * Define an offset on the texture to scale the v coordinates of the UVs
  20151. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20152. */
  20153. vScale: number;
  20154. /**
  20155. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20156. * @see http://doc.babylonjs.com/how_to/more_materials
  20157. */
  20158. uAng: number;
  20159. /**
  20160. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20161. * @see http://doc.babylonjs.com/how_to/more_materials
  20162. */
  20163. vAng: number;
  20164. /**
  20165. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20166. * @see http://doc.babylonjs.com/how_to/more_materials
  20167. */
  20168. wAng: number;
  20169. /**
  20170. * Defines the center of rotation (U)
  20171. */
  20172. uRotationCenter: number;
  20173. /**
  20174. * Defines the center of rotation (V)
  20175. */
  20176. vRotationCenter: number;
  20177. /**
  20178. * Defines the center of rotation (W)
  20179. */
  20180. wRotationCenter: number;
  20181. /**
  20182. * Are mip maps generated for this texture or not.
  20183. */
  20184. get noMipmap(): boolean;
  20185. /**
  20186. * List of inspectable custom properties (used by the Inspector)
  20187. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20188. */
  20189. inspectableCustomProperties: Nullable<IInspectable[]>;
  20190. private _noMipmap;
  20191. /** @hidden */
  20192. _invertY: boolean;
  20193. private _rowGenerationMatrix;
  20194. private _cachedTextureMatrix;
  20195. private _projectionModeMatrix;
  20196. private _t0;
  20197. private _t1;
  20198. private _t2;
  20199. private _cachedUOffset;
  20200. private _cachedVOffset;
  20201. private _cachedUScale;
  20202. private _cachedVScale;
  20203. private _cachedUAng;
  20204. private _cachedVAng;
  20205. private _cachedWAng;
  20206. private _cachedProjectionMatrixId;
  20207. private _cachedCoordinatesMode;
  20208. /** @hidden */
  20209. protected _initialSamplingMode: number;
  20210. /** @hidden */
  20211. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20212. private _deleteBuffer;
  20213. protected _format: Nullable<number>;
  20214. private _delayedOnLoad;
  20215. private _delayedOnError;
  20216. private _mimeType?;
  20217. /**
  20218. * Observable triggered once the texture has been loaded.
  20219. */
  20220. onLoadObservable: Observable<Texture>;
  20221. protected _isBlocking: boolean;
  20222. /**
  20223. * Is the texture preventing material to render while loading.
  20224. * If false, a default texture will be used instead of the loading one during the preparation step.
  20225. */
  20226. set isBlocking(value: boolean);
  20227. get isBlocking(): boolean;
  20228. /**
  20229. * Get the current sampling mode associated with the texture.
  20230. */
  20231. get samplingMode(): number;
  20232. /**
  20233. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20234. */
  20235. get invertY(): boolean;
  20236. /**
  20237. * Instantiates a new texture.
  20238. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20239. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20240. * @param url defines the url of the picture to load as a texture
  20241. * @param scene defines the scene or engine the texture will belong to
  20242. * @param noMipmap defines if the texture will require mip maps or not
  20243. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20244. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20245. * @param onLoad defines a callback triggered when the texture has been loaded
  20246. * @param onError defines a callback triggered when an error occurred during the loading session
  20247. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20248. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20249. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20250. * @param mimeType defines an optional mime type information
  20251. */
  20252. 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);
  20253. /**
  20254. * Update the url (and optional buffer) of this texture if url was null during construction.
  20255. * @param url the url of the texture
  20256. * @param buffer the buffer of the texture (defaults to null)
  20257. * @param onLoad callback called when the texture is loaded (defaults to null)
  20258. */
  20259. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20260. /**
  20261. * Finish the loading sequence of a texture flagged as delayed load.
  20262. * @hidden
  20263. */
  20264. delayLoad(): void;
  20265. private _prepareRowForTextureGeneration;
  20266. /**
  20267. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20268. * @returns the transform matrix of the texture.
  20269. */
  20270. getTextureMatrix(uBase?: number): Matrix;
  20271. /**
  20272. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20273. * @returns The reflection texture transform
  20274. */
  20275. getReflectionTextureMatrix(): Matrix;
  20276. /**
  20277. * Clones the texture.
  20278. * @returns the cloned texture
  20279. */
  20280. clone(): Texture;
  20281. /**
  20282. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20283. * @returns The JSON representation of the texture
  20284. */
  20285. serialize(): any;
  20286. /**
  20287. * Get the current class name of the texture useful for serialization or dynamic coding.
  20288. * @returns "Texture"
  20289. */
  20290. getClassName(): string;
  20291. /**
  20292. * Dispose the texture and release its associated resources.
  20293. */
  20294. dispose(): void;
  20295. /**
  20296. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20297. * @param parsedTexture Define the JSON representation of the texture
  20298. * @param scene Define the scene the parsed texture should be instantiated in
  20299. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20300. * @returns The parsed texture if successful
  20301. */
  20302. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20303. /**
  20304. * Creates a texture from its base 64 representation.
  20305. * @param data Define the base64 payload without the data: prefix
  20306. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20307. * @param scene Define the scene the texture should belong to
  20308. * @param noMipmap Forces the texture to not create mip map information if true
  20309. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20310. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20311. * @param onLoad define a callback triggered when the texture has been loaded
  20312. * @param onError define a callback triggered when an error occurred during the loading session
  20313. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20314. * @returns the created texture
  20315. */
  20316. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20317. /**
  20318. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20319. * @param data Define the base64 payload without the data: prefix
  20320. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20321. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20322. * @param scene Define the scene the texture should belong to
  20323. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20324. * @param noMipmap Forces the texture to not create mip map information if true
  20325. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20326. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20327. * @param onLoad define a callback triggered when the texture has been loaded
  20328. * @param onError define a callback triggered when an error occurred during the loading session
  20329. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20330. * @returns the created texture
  20331. */
  20332. 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;
  20333. }
  20334. }
  20335. declare module BABYLON {
  20336. /**
  20337. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20338. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20339. */
  20340. export class PostProcessManager {
  20341. private _scene;
  20342. private _indexBuffer;
  20343. private _vertexBuffers;
  20344. /**
  20345. * Creates a new instance PostProcess
  20346. * @param scene The scene that the post process is associated with.
  20347. */
  20348. constructor(scene: Scene);
  20349. private _prepareBuffers;
  20350. private _buildIndexBuffer;
  20351. /**
  20352. * Rebuilds the vertex buffers of the manager.
  20353. * @hidden
  20354. */
  20355. _rebuild(): void;
  20356. /**
  20357. * Prepares a frame to be run through a post process.
  20358. * @param sourceTexture The input texture to the post procesess. (default: null)
  20359. * @param postProcesses An array of post processes to be run. (default: null)
  20360. * @returns True if the post processes were able to be run.
  20361. * @hidden
  20362. */
  20363. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20364. /**
  20365. * Manually render a set of post processes to a texture.
  20366. * @param postProcesses An array of post processes to be run.
  20367. * @param targetTexture The target texture to render to.
  20368. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20369. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20370. * @param lodLevel defines which lod of the texture to render to
  20371. */
  20372. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20373. /**
  20374. * Finalize the result of the output of the postprocesses.
  20375. * @param doNotPresent If true the result will not be displayed to the screen.
  20376. * @param targetTexture The target texture to render to.
  20377. * @param faceIndex The index of the face to bind the target texture to.
  20378. * @param postProcesses The array of post processes to render.
  20379. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20380. * @hidden
  20381. */
  20382. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20383. /**
  20384. * Disposes of the post process manager.
  20385. */
  20386. dispose(): void;
  20387. }
  20388. }
  20389. declare module BABYLON {
  20390. /**
  20391. * This Helps creating a texture that will be created from a camera in your scene.
  20392. * It is basically a dynamic texture that could be used to create special effects for instance.
  20393. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20394. */
  20395. export class RenderTargetTexture extends Texture {
  20396. isCube: boolean;
  20397. /**
  20398. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20399. */
  20400. static readonly REFRESHRATE_RENDER_ONCE: number;
  20401. /**
  20402. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20403. */
  20404. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20405. /**
  20406. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20407. * the central point of your effect and can save a lot of performances.
  20408. */
  20409. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20410. /**
  20411. * Use this predicate to dynamically define the list of mesh you want to render.
  20412. * If set, the renderList property will be overwritten.
  20413. */
  20414. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20415. private _renderList;
  20416. /**
  20417. * Use this list to define the list of mesh you want to render.
  20418. */
  20419. get renderList(): Nullable<Array<AbstractMesh>>;
  20420. set renderList(value: Nullable<Array<AbstractMesh>>);
  20421. /**
  20422. * Use this function to overload the renderList array at rendering time.
  20423. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20424. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20425. * the cube (if the RTT is a cube, else layerOrFace=0).
  20426. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20427. */
  20428. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20429. private _hookArray;
  20430. /**
  20431. * Define if particles should be rendered in your texture.
  20432. */
  20433. renderParticles: boolean;
  20434. /**
  20435. * Define if sprites should be rendered in your texture.
  20436. */
  20437. renderSprites: boolean;
  20438. /**
  20439. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20440. */
  20441. coordinatesMode: number;
  20442. /**
  20443. * Define the camera used to render the texture.
  20444. */
  20445. activeCamera: Nullable<Camera>;
  20446. /**
  20447. * Override the render function of the texture with your own one.
  20448. */
  20449. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20450. /**
  20451. * Define if camera post processes should be use while rendering the texture.
  20452. */
  20453. useCameraPostProcesses: boolean;
  20454. /**
  20455. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20456. */
  20457. ignoreCameraViewport: boolean;
  20458. private _postProcessManager;
  20459. private _postProcesses;
  20460. private _resizeObserver;
  20461. /**
  20462. * An event triggered when the texture is unbind.
  20463. */
  20464. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20465. /**
  20466. * An event triggered when the texture is unbind.
  20467. */
  20468. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20469. private _onAfterUnbindObserver;
  20470. /**
  20471. * Set a after unbind callback in the texture.
  20472. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20473. */
  20474. set onAfterUnbind(callback: () => void);
  20475. /**
  20476. * An event triggered before rendering the texture
  20477. */
  20478. onBeforeRenderObservable: Observable<number>;
  20479. private _onBeforeRenderObserver;
  20480. /**
  20481. * Set a before render callback in the texture.
  20482. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20483. */
  20484. set onBeforeRender(callback: (faceIndex: number) => void);
  20485. /**
  20486. * An event triggered after rendering the texture
  20487. */
  20488. onAfterRenderObservable: Observable<number>;
  20489. private _onAfterRenderObserver;
  20490. /**
  20491. * Set a after render callback in the texture.
  20492. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20493. */
  20494. set onAfterRender(callback: (faceIndex: number) => void);
  20495. /**
  20496. * An event triggered after the texture clear
  20497. */
  20498. onClearObservable: Observable<Engine>;
  20499. private _onClearObserver;
  20500. /**
  20501. * Set a clear callback in the texture.
  20502. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20503. */
  20504. set onClear(callback: (Engine: Engine) => void);
  20505. /**
  20506. * An event triggered when the texture is resized.
  20507. */
  20508. onResizeObservable: Observable<RenderTargetTexture>;
  20509. /**
  20510. * Define the clear color of the Render Target if it should be different from the scene.
  20511. */
  20512. clearColor: Color4;
  20513. protected _size: number | {
  20514. width: number;
  20515. height: number;
  20516. layers?: number;
  20517. };
  20518. protected _initialSizeParameter: number | {
  20519. width: number;
  20520. height: number;
  20521. } | {
  20522. ratio: number;
  20523. };
  20524. protected _sizeRatio: Nullable<number>;
  20525. /** @hidden */
  20526. _generateMipMaps: boolean;
  20527. protected _renderingManager: RenderingManager;
  20528. /** @hidden */
  20529. _waitingRenderList: string[];
  20530. protected _doNotChangeAspectRatio: boolean;
  20531. protected _currentRefreshId: number;
  20532. protected _refreshRate: number;
  20533. protected _textureMatrix: Matrix;
  20534. protected _samples: number;
  20535. protected _renderTargetOptions: RenderTargetCreationOptions;
  20536. /**
  20537. * Gets render target creation options that were used.
  20538. */
  20539. get renderTargetOptions(): RenderTargetCreationOptions;
  20540. protected _engine: Engine;
  20541. protected _onRatioRescale(): void;
  20542. /**
  20543. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20544. * It must define where the camera used to render the texture is set
  20545. */
  20546. boundingBoxPosition: Vector3;
  20547. private _boundingBoxSize;
  20548. /**
  20549. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20550. * When defined, the cubemap will switch to local mode
  20551. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20552. * @example https://www.babylonjs-playground.com/#RNASML
  20553. */
  20554. set boundingBoxSize(value: Vector3);
  20555. get boundingBoxSize(): Vector3;
  20556. /**
  20557. * In case the RTT has been created with a depth texture, get the associated
  20558. * depth texture.
  20559. * Otherwise, return null.
  20560. */
  20561. get depthStencilTexture(): Nullable<InternalTexture>;
  20562. /**
  20563. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20564. * or used a shadow, depth texture...
  20565. * @param name The friendly name of the texture
  20566. * @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)
  20567. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20568. * @param generateMipMaps True if mip maps need to be generated after render.
  20569. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20570. * @param type The type of the buffer in the RTT (int, half float, float...)
  20571. * @param isCube True if a cube texture needs to be created
  20572. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20573. * @param generateDepthBuffer True to generate a depth buffer
  20574. * @param generateStencilBuffer True to generate a stencil buffer
  20575. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20576. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20577. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20578. */
  20579. constructor(name: string, size: number | {
  20580. width: number;
  20581. height: number;
  20582. layers?: number;
  20583. } | {
  20584. ratio: number;
  20585. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20586. /**
  20587. * Creates a depth stencil texture.
  20588. * This is only available in WebGL 2 or with the depth texture extension available.
  20589. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20590. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20591. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20592. */
  20593. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20594. private _processSizeParameter;
  20595. /**
  20596. * Define the number of samples to use in case of MSAA.
  20597. * It defaults to one meaning no MSAA has been enabled.
  20598. */
  20599. get samples(): number;
  20600. set samples(value: number);
  20601. /**
  20602. * Resets the refresh counter of the texture and start bak from scratch.
  20603. * Could be useful to regenerate the texture if it is setup to render only once.
  20604. */
  20605. resetRefreshCounter(): void;
  20606. /**
  20607. * Define the refresh rate of the texture or the rendering frequency.
  20608. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20609. */
  20610. get refreshRate(): number;
  20611. set refreshRate(value: number);
  20612. /**
  20613. * Adds a post process to the render target rendering passes.
  20614. * @param postProcess define the post process to add
  20615. */
  20616. addPostProcess(postProcess: PostProcess): void;
  20617. /**
  20618. * Clear all the post processes attached to the render target
  20619. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20620. */
  20621. clearPostProcesses(dispose?: boolean): void;
  20622. /**
  20623. * Remove one of the post process from the list of attached post processes to the texture
  20624. * @param postProcess define the post process to remove from the list
  20625. */
  20626. removePostProcess(postProcess: PostProcess): void;
  20627. /** @hidden */
  20628. _shouldRender(): boolean;
  20629. /**
  20630. * Gets the actual render size of the texture.
  20631. * @returns the width of the render size
  20632. */
  20633. getRenderSize(): number;
  20634. /**
  20635. * Gets the actual render width of the texture.
  20636. * @returns the width of the render size
  20637. */
  20638. getRenderWidth(): number;
  20639. /**
  20640. * Gets the actual render height of the texture.
  20641. * @returns the height of the render size
  20642. */
  20643. getRenderHeight(): number;
  20644. /**
  20645. * Gets the actual number of layers of the texture.
  20646. * @returns the number of layers
  20647. */
  20648. getRenderLayers(): number;
  20649. /**
  20650. * Get if the texture can be rescaled or not.
  20651. */
  20652. get canRescale(): boolean;
  20653. /**
  20654. * Resize the texture using a ratio.
  20655. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20656. */
  20657. scale(ratio: number): void;
  20658. /**
  20659. * Get the texture reflection matrix used to rotate/transform the reflection.
  20660. * @returns the reflection matrix
  20661. */
  20662. getReflectionTextureMatrix(): Matrix;
  20663. /**
  20664. * Resize the texture to a new desired size.
  20665. * Be carrefull as it will recreate all the data in the new texture.
  20666. * @param size Define the new size. It can be:
  20667. * - a number for squared texture,
  20668. * - an object containing { width: number, height: number }
  20669. * - or an object containing a ratio { ratio: number }
  20670. */
  20671. resize(size: number | {
  20672. width: number;
  20673. height: number;
  20674. } | {
  20675. ratio: number;
  20676. }): void;
  20677. private _defaultRenderListPrepared;
  20678. /**
  20679. * Renders all the objects from the render list into the texture.
  20680. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20681. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20682. */
  20683. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20684. private _bestReflectionRenderTargetDimension;
  20685. private _prepareRenderingManager;
  20686. /**
  20687. * @hidden
  20688. * @param faceIndex face index to bind to if this is a cubetexture
  20689. * @param layer defines the index of the texture to bind in the array
  20690. */
  20691. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20692. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20693. private renderToTarget;
  20694. /**
  20695. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20696. * This allowed control for front to back rendering or reversly depending of the special needs.
  20697. *
  20698. * @param renderingGroupId The rendering group id corresponding to its index
  20699. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20700. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20701. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20702. */
  20703. 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;
  20704. /**
  20705. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20706. *
  20707. * @param renderingGroupId The rendering group id corresponding to its index
  20708. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20709. */
  20710. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20711. /**
  20712. * Clones the texture.
  20713. * @returns the cloned texture
  20714. */
  20715. clone(): RenderTargetTexture;
  20716. /**
  20717. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20718. * @returns The JSON representation of the texture
  20719. */
  20720. serialize(): any;
  20721. /**
  20722. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20723. */
  20724. disposeFramebufferObjects(): void;
  20725. /**
  20726. * Dispose the texture and release its associated resources.
  20727. */
  20728. dispose(): void;
  20729. /** @hidden */
  20730. _rebuild(): void;
  20731. /**
  20732. * Clear the info related to rendering groups preventing retention point in material dispose.
  20733. */
  20734. freeRenderingGroups(): void;
  20735. /**
  20736. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20737. * @returns the view count
  20738. */
  20739. getViewCount(): number;
  20740. }
  20741. }
  20742. declare module BABYLON {
  20743. /**
  20744. * Options for compiling materials.
  20745. */
  20746. export interface IMaterialCompilationOptions {
  20747. /**
  20748. * Defines whether clip planes are enabled.
  20749. */
  20750. clipPlane: boolean;
  20751. /**
  20752. * Defines whether instances are enabled.
  20753. */
  20754. useInstances: boolean;
  20755. }
  20756. /**
  20757. * Base class for the main features of a material in Babylon.js
  20758. */
  20759. export class Material implements IAnimatable {
  20760. /**
  20761. * Returns the triangle fill mode
  20762. */
  20763. static readonly TriangleFillMode: number;
  20764. /**
  20765. * Returns the wireframe mode
  20766. */
  20767. static readonly WireFrameFillMode: number;
  20768. /**
  20769. * Returns the point fill mode
  20770. */
  20771. static readonly PointFillMode: number;
  20772. /**
  20773. * Returns the point list draw mode
  20774. */
  20775. static readonly PointListDrawMode: number;
  20776. /**
  20777. * Returns the line list draw mode
  20778. */
  20779. static readonly LineListDrawMode: number;
  20780. /**
  20781. * Returns the line loop draw mode
  20782. */
  20783. static readonly LineLoopDrawMode: number;
  20784. /**
  20785. * Returns the line strip draw mode
  20786. */
  20787. static readonly LineStripDrawMode: number;
  20788. /**
  20789. * Returns the triangle strip draw mode
  20790. */
  20791. static readonly TriangleStripDrawMode: number;
  20792. /**
  20793. * Returns the triangle fan draw mode
  20794. */
  20795. static readonly TriangleFanDrawMode: number;
  20796. /**
  20797. * Stores the clock-wise side orientation
  20798. */
  20799. static readonly ClockWiseSideOrientation: number;
  20800. /**
  20801. * Stores the counter clock-wise side orientation
  20802. */
  20803. static readonly CounterClockWiseSideOrientation: number;
  20804. /**
  20805. * The dirty texture flag value
  20806. */
  20807. static readonly TextureDirtyFlag: number;
  20808. /**
  20809. * The dirty light flag value
  20810. */
  20811. static readonly LightDirtyFlag: number;
  20812. /**
  20813. * The dirty fresnel flag value
  20814. */
  20815. static readonly FresnelDirtyFlag: number;
  20816. /**
  20817. * The dirty attribute flag value
  20818. */
  20819. static readonly AttributesDirtyFlag: number;
  20820. /**
  20821. * The dirty misc flag value
  20822. */
  20823. static readonly MiscDirtyFlag: number;
  20824. /**
  20825. * The all dirty flag value
  20826. */
  20827. static readonly AllDirtyFlag: number;
  20828. /**
  20829. * The ID of the material
  20830. */
  20831. id: string;
  20832. /**
  20833. * Gets or sets the unique id of the material
  20834. */
  20835. uniqueId: number;
  20836. /**
  20837. * The name of the material
  20838. */
  20839. name: string;
  20840. /**
  20841. * Gets or sets user defined metadata
  20842. */
  20843. metadata: any;
  20844. /**
  20845. * For internal use only. Please do not use.
  20846. */
  20847. reservedDataStore: any;
  20848. /**
  20849. * Specifies if the ready state should be checked on each call
  20850. */
  20851. checkReadyOnEveryCall: boolean;
  20852. /**
  20853. * Specifies if the ready state should be checked once
  20854. */
  20855. checkReadyOnlyOnce: boolean;
  20856. /**
  20857. * The state of the material
  20858. */
  20859. state: string;
  20860. /**
  20861. * The alpha value of the material
  20862. */
  20863. protected _alpha: number;
  20864. /**
  20865. * List of inspectable custom properties (used by the Inspector)
  20866. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20867. */
  20868. inspectableCustomProperties: IInspectable[];
  20869. /**
  20870. * Sets the alpha value of the material
  20871. */
  20872. set alpha(value: number);
  20873. /**
  20874. * Gets the alpha value of the material
  20875. */
  20876. get alpha(): number;
  20877. /**
  20878. * Specifies if back face culling is enabled
  20879. */
  20880. protected _backFaceCulling: boolean;
  20881. /**
  20882. * Sets the back-face culling state
  20883. */
  20884. set backFaceCulling(value: boolean);
  20885. /**
  20886. * Gets the back-face culling state
  20887. */
  20888. get backFaceCulling(): boolean;
  20889. /**
  20890. * Stores the value for side orientation
  20891. */
  20892. sideOrientation: number;
  20893. /**
  20894. * Callback triggered when the material is compiled
  20895. */
  20896. onCompiled: Nullable<(effect: Effect) => void>;
  20897. /**
  20898. * Callback triggered when an error occurs
  20899. */
  20900. onError: Nullable<(effect: Effect, errors: string) => void>;
  20901. /**
  20902. * Callback triggered to get the render target textures
  20903. */
  20904. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20905. /**
  20906. * Gets a boolean indicating that current material needs to register RTT
  20907. */
  20908. get hasRenderTargetTextures(): boolean;
  20909. /**
  20910. * Specifies if the material should be serialized
  20911. */
  20912. doNotSerialize: boolean;
  20913. /**
  20914. * @hidden
  20915. */
  20916. _storeEffectOnSubMeshes: boolean;
  20917. /**
  20918. * Stores the animations for the material
  20919. */
  20920. animations: Nullable<Array<Animation>>;
  20921. /**
  20922. * An event triggered when the material is disposed
  20923. */
  20924. onDisposeObservable: Observable<Material>;
  20925. /**
  20926. * An observer which watches for dispose events
  20927. */
  20928. private _onDisposeObserver;
  20929. private _onUnBindObservable;
  20930. /**
  20931. * Called during a dispose event
  20932. */
  20933. set onDispose(callback: () => void);
  20934. private _onBindObservable;
  20935. /**
  20936. * An event triggered when the material is bound
  20937. */
  20938. get onBindObservable(): Observable<AbstractMesh>;
  20939. /**
  20940. * An observer which watches for bind events
  20941. */
  20942. private _onBindObserver;
  20943. /**
  20944. * Called during a bind event
  20945. */
  20946. set onBind(callback: (Mesh: AbstractMesh) => void);
  20947. /**
  20948. * An event triggered when the material is unbound
  20949. */
  20950. get onUnBindObservable(): Observable<Material>;
  20951. /**
  20952. * Stores the value of the alpha mode
  20953. */
  20954. private _alphaMode;
  20955. /**
  20956. * Sets the value of the alpha mode.
  20957. *
  20958. * | Value | Type | Description |
  20959. * | --- | --- | --- |
  20960. * | 0 | ALPHA_DISABLE | |
  20961. * | 1 | ALPHA_ADD | |
  20962. * | 2 | ALPHA_COMBINE | |
  20963. * | 3 | ALPHA_SUBTRACT | |
  20964. * | 4 | ALPHA_MULTIPLY | |
  20965. * | 5 | ALPHA_MAXIMIZED | |
  20966. * | 6 | ALPHA_ONEONE | |
  20967. * | 7 | ALPHA_PREMULTIPLIED | |
  20968. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20969. * | 9 | ALPHA_INTERPOLATE | |
  20970. * | 10 | ALPHA_SCREENMODE | |
  20971. *
  20972. */
  20973. set alphaMode(value: number);
  20974. /**
  20975. * Gets the value of the alpha mode
  20976. */
  20977. get alphaMode(): number;
  20978. /**
  20979. * Stores the state of the need depth pre-pass value
  20980. */
  20981. private _needDepthPrePass;
  20982. /**
  20983. * Sets the need depth pre-pass value
  20984. */
  20985. set needDepthPrePass(value: boolean);
  20986. /**
  20987. * Gets the depth pre-pass value
  20988. */
  20989. get needDepthPrePass(): boolean;
  20990. /**
  20991. * Specifies if depth writing should be disabled
  20992. */
  20993. disableDepthWrite: boolean;
  20994. /**
  20995. * Specifies if depth writing should be forced
  20996. */
  20997. forceDepthWrite: boolean;
  20998. /**
  20999. * Specifies the depth function that should be used. 0 means the default engine function
  21000. */
  21001. depthFunction: number;
  21002. /**
  21003. * Specifies if there should be a separate pass for culling
  21004. */
  21005. separateCullingPass: boolean;
  21006. /**
  21007. * Stores the state specifing if fog should be enabled
  21008. */
  21009. private _fogEnabled;
  21010. /**
  21011. * Sets the state for enabling fog
  21012. */
  21013. set fogEnabled(value: boolean);
  21014. /**
  21015. * Gets the value of the fog enabled state
  21016. */
  21017. get fogEnabled(): boolean;
  21018. /**
  21019. * Stores the size of points
  21020. */
  21021. pointSize: number;
  21022. /**
  21023. * Stores the z offset value
  21024. */
  21025. zOffset: number;
  21026. /**
  21027. * Gets a value specifying if wireframe mode is enabled
  21028. */
  21029. get wireframe(): boolean;
  21030. /**
  21031. * Sets the state of wireframe mode
  21032. */
  21033. set wireframe(value: boolean);
  21034. /**
  21035. * Gets the value specifying if point clouds are enabled
  21036. */
  21037. get pointsCloud(): boolean;
  21038. /**
  21039. * Sets the state of point cloud mode
  21040. */
  21041. set pointsCloud(value: boolean);
  21042. /**
  21043. * Gets the material fill mode
  21044. */
  21045. get fillMode(): number;
  21046. /**
  21047. * Sets the material fill mode
  21048. */
  21049. set fillMode(value: number);
  21050. /**
  21051. * @hidden
  21052. * Stores the effects for the material
  21053. */
  21054. _effect: Nullable<Effect>;
  21055. /**
  21056. * Specifies if uniform buffers should be used
  21057. */
  21058. private _useUBO;
  21059. /**
  21060. * Stores a reference to the scene
  21061. */
  21062. private _scene;
  21063. /**
  21064. * Stores the fill mode state
  21065. */
  21066. private _fillMode;
  21067. /**
  21068. * Specifies if the depth write state should be cached
  21069. */
  21070. private _cachedDepthWriteState;
  21071. /**
  21072. * Specifies if the depth function state should be cached
  21073. */
  21074. private _cachedDepthFunctionState;
  21075. /**
  21076. * Stores the uniform buffer
  21077. */
  21078. protected _uniformBuffer: UniformBuffer;
  21079. /** @hidden */
  21080. _indexInSceneMaterialArray: number;
  21081. /** @hidden */
  21082. meshMap: Nullable<{
  21083. [id: string]: AbstractMesh | undefined;
  21084. }>;
  21085. /**
  21086. * Creates a material instance
  21087. * @param name defines the name of the material
  21088. * @param scene defines the scene to reference
  21089. * @param doNotAdd specifies if the material should be added to the scene
  21090. */
  21091. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21092. /**
  21093. * Returns a string representation of the current material
  21094. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21095. * @returns a string with material information
  21096. */
  21097. toString(fullDetails?: boolean): string;
  21098. /**
  21099. * Gets the class name of the material
  21100. * @returns a string with the class name of the material
  21101. */
  21102. getClassName(): string;
  21103. /**
  21104. * Specifies if updates for the material been locked
  21105. */
  21106. get isFrozen(): boolean;
  21107. /**
  21108. * Locks updates for the material
  21109. */
  21110. freeze(): void;
  21111. /**
  21112. * Unlocks updates for the material
  21113. */
  21114. unfreeze(): void;
  21115. /**
  21116. * Specifies if the material is ready to be used
  21117. * @param mesh defines the mesh to check
  21118. * @param useInstances specifies if instances should be used
  21119. * @returns a boolean indicating if the material is ready to be used
  21120. */
  21121. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21122. /**
  21123. * Specifies that the submesh is ready to be used
  21124. * @param mesh defines the mesh to check
  21125. * @param subMesh defines which submesh to check
  21126. * @param useInstances specifies that instances should be used
  21127. * @returns a boolean indicating that the submesh is ready or not
  21128. */
  21129. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21130. /**
  21131. * Returns the material effect
  21132. * @returns the effect associated with the material
  21133. */
  21134. getEffect(): Nullable<Effect>;
  21135. /**
  21136. * Returns the current scene
  21137. * @returns a Scene
  21138. */
  21139. getScene(): Scene;
  21140. /**
  21141. * Specifies if the material will require alpha blending
  21142. * @returns a boolean specifying if alpha blending is needed
  21143. */
  21144. needAlphaBlending(): boolean;
  21145. /**
  21146. * Specifies if the mesh will require alpha blending
  21147. * @param mesh defines the mesh to check
  21148. * @returns a boolean specifying if alpha blending is needed for the mesh
  21149. */
  21150. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21151. /**
  21152. * Specifies if this material should be rendered in alpha test mode
  21153. * @returns a boolean specifying if an alpha test is needed.
  21154. */
  21155. needAlphaTesting(): boolean;
  21156. /**
  21157. * Gets the texture used for the alpha test
  21158. * @returns the texture to use for alpha testing
  21159. */
  21160. getAlphaTestTexture(): Nullable<BaseTexture>;
  21161. /**
  21162. * Marks the material to indicate that it needs to be re-calculated
  21163. */
  21164. markDirty(): void;
  21165. /** @hidden */
  21166. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21167. /**
  21168. * Binds the material to the mesh
  21169. * @param world defines the world transformation matrix
  21170. * @param mesh defines the mesh to bind the material to
  21171. */
  21172. bind(world: Matrix, mesh?: Mesh): void;
  21173. /**
  21174. * Binds the submesh to the material
  21175. * @param world defines the world transformation matrix
  21176. * @param mesh defines the mesh containing the submesh
  21177. * @param subMesh defines the submesh to bind the material to
  21178. */
  21179. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21180. /**
  21181. * Binds the world matrix to the material
  21182. * @param world defines the world transformation matrix
  21183. */
  21184. bindOnlyWorldMatrix(world: Matrix): void;
  21185. /**
  21186. * Binds the scene's uniform buffer to the effect.
  21187. * @param effect defines the effect to bind to the scene uniform buffer
  21188. * @param sceneUbo defines the uniform buffer storing scene data
  21189. */
  21190. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21191. /**
  21192. * Binds the view matrix to the effect
  21193. * @param effect defines the effect to bind the view matrix to
  21194. */
  21195. bindView(effect: Effect): void;
  21196. /**
  21197. * Binds the view projection matrix to the effect
  21198. * @param effect defines the effect to bind the view projection matrix to
  21199. */
  21200. bindViewProjection(effect: Effect): void;
  21201. /**
  21202. * Specifies if material alpha testing should be turned on for the mesh
  21203. * @param mesh defines the mesh to check
  21204. */
  21205. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21206. /**
  21207. * Processes to execute after binding the material to a mesh
  21208. * @param mesh defines the rendered mesh
  21209. */
  21210. protected _afterBind(mesh?: Mesh): void;
  21211. /**
  21212. * Unbinds the material from the mesh
  21213. */
  21214. unbind(): void;
  21215. /**
  21216. * Gets the active textures from the material
  21217. * @returns an array of textures
  21218. */
  21219. getActiveTextures(): BaseTexture[];
  21220. /**
  21221. * Specifies if the material uses a texture
  21222. * @param texture defines the texture to check against the material
  21223. * @returns a boolean specifying if the material uses the texture
  21224. */
  21225. hasTexture(texture: BaseTexture): boolean;
  21226. /**
  21227. * Makes a duplicate of the material, and gives it a new name
  21228. * @param name defines the new name for the duplicated material
  21229. * @returns the cloned material
  21230. */
  21231. clone(name: string): Nullable<Material>;
  21232. /**
  21233. * Gets the meshes bound to the material
  21234. * @returns an array of meshes bound to the material
  21235. */
  21236. getBindedMeshes(): AbstractMesh[];
  21237. /**
  21238. * Force shader compilation
  21239. * @param mesh defines the mesh associated with this material
  21240. * @param onCompiled defines a function to execute once the material is compiled
  21241. * @param options defines the options to configure the compilation
  21242. * @param onError defines a function to execute if the material fails compiling
  21243. */
  21244. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21245. /**
  21246. * Force shader compilation
  21247. * @param mesh defines the mesh that will use this material
  21248. * @param options defines additional options for compiling the shaders
  21249. * @returns a promise that resolves when the compilation completes
  21250. */
  21251. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21252. private static readonly _AllDirtyCallBack;
  21253. private static readonly _ImageProcessingDirtyCallBack;
  21254. private static readonly _TextureDirtyCallBack;
  21255. private static readonly _FresnelDirtyCallBack;
  21256. private static readonly _MiscDirtyCallBack;
  21257. private static readonly _LightsDirtyCallBack;
  21258. private static readonly _AttributeDirtyCallBack;
  21259. private static _FresnelAndMiscDirtyCallBack;
  21260. private static _TextureAndMiscDirtyCallBack;
  21261. private static readonly _DirtyCallbackArray;
  21262. private static readonly _RunDirtyCallBacks;
  21263. /**
  21264. * Marks a define in the material to indicate that it needs to be re-computed
  21265. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21266. */
  21267. markAsDirty(flag: number): void;
  21268. /**
  21269. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21270. * @param func defines a function which checks material defines against the submeshes
  21271. */
  21272. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21273. /**
  21274. * Indicates that we need to re-calculated for all submeshes
  21275. */
  21276. protected _markAllSubMeshesAsAllDirty(): void;
  21277. /**
  21278. * Indicates that image processing needs to be re-calculated for all submeshes
  21279. */
  21280. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21281. /**
  21282. * Indicates that textures need to be re-calculated for all submeshes
  21283. */
  21284. protected _markAllSubMeshesAsTexturesDirty(): void;
  21285. /**
  21286. * Indicates that fresnel needs to be re-calculated for all submeshes
  21287. */
  21288. protected _markAllSubMeshesAsFresnelDirty(): void;
  21289. /**
  21290. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21291. */
  21292. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21293. /**
  21294. * Indicates that lights need to be re-calculated for all submeshes
  21295. */
  21296. protected _markAllSubMeshesAsLightsDirty(): void;
  21297. /**
  21298. * Indicates that attributes need to be re-calculated for all submeshes
  21299. */
  21300. protected _markAllSubMeshesAsAttributesDirty(): void;
  21301. /**
  21302. * Indicates that misc needs to be re-calculated for all submeshes
  21303. */
  21304. protected _markAllSubMeshesAsMiscDirty(): void;
  21305. /**
  21306. * Indicates that textures and misc need to be re-calculated for all submeshes
  21307. */
  21308. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21309. /**
  21310. * Disposes the material
  21311. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21312. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21313. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21314. */
  21315. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21316. /** @hidden */
  21317. private releaseVertexArrayObject;
  21318. /**
  21319. * Serializes this material
  21320. * @returns the serialized material object
  21321. */
  21322. serialize(): any;
  21323. /**
  21324. * Creates a material from parsed material data
  21325. * @param parsedMaterial defines parsed material data
  21326. * @param scene defines the hosting scene
  21327. * @param rootUrl defines the root URL to use to load textures
  21328. * @returns a new material
  21329. */
  21330. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21331. }
  21332. }
  21333. declare module BABYLON {
  21334. /**
  21335. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21336. * separate meshes. This can be use to improve performances.
  21337. * @see http://doc.babylonjs.com/how_to/multi_materials
  21338. */
  21339. export class MultiMaterial extends Material {
  21340. private _subMaterials;
  21341. /**
  21342. * Gets or Sets the list of Materials used within the multi material.
  21343. * They need to be ordered according to the submeshes order in the associated mesh
  21344. */
  21345. get subMaterials(): Nullable<Material>[];
  21346. set subMaterials(value: Nullable<Material>[]);
  21347. /**
  21348. * Function used to align with Node.getChildren()
  21349. * @returns the list of Materials used within the multi material
  21350. */
  21351. getChildren(): Nullable<Material>[];
  21352. /**
  21353. * Instantiates a new Multi Material
  21354. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21355. * separate meshes. This can be use to improve performances.
  21356. * @see http://doc.babylonjs.com/how_to/multi_materials
  21357. * @param name Define the name in the scene
  21358. * @param scene Define the scene the material belongs to
  21359. */
  21360. constructor(name: string, scene: Scene);
  21361. private _hookArray;
  21362. /**
  21363. * Get one of the submaterial by its index in the submaterials array
  21364. * @param index The index to look the sub material at
  21365. * @returns The Material if the index has been defined
  21366. */
  21367. getSubMaterial(index: number): Nullable<Material>;
  21368. /**
  21369. * Get the list of active textures for the whole sub materials list.
  21370. * @returns All the textures that will be used during the rendering
  21371. */
  21372. getActiveTextures(): BaseTexture[];
  21373. /**
  21374. * Gets the current class name of the material e.g. "MultiMaterial"
  21375. * Mainly use in serialization.
  21376. * @returns the class name
  21377. */
  21378. getClassName(): string;
  21379. /**
  21380. * Checks if the material is ready to render the requested sub mesh
  21381. * @param mesh Define the mesh the submesh belongs to
  21382. * @param subMesh Define the sub mesh to look readyness for
  21383. * @param useInstances Define whether or not the material is used with instances
  21384. * @returns true if ready, otherwise false
  21385. */
  21386. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21387. /**
  21388. * Clones the current material and its related sub materials
  21389. * @param name Define the name of the newly cloned material
  21390. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21391. * @returns the cloned material
  21392. */
  21393. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21394. /**
  21395. * Serializes the materials into a JSON representation.
  21396. * @returns the JSON representation
  21397. */
  21398. serialize(): any;
  21399. /**
  21400. * Dispose the material and release its associated resources
  21401. * @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)
  21402. * @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)
  21403. * @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)
  21404. */
  21405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21406. /**
  21407. * Creates a MultiMaterial from parsed MultiMaterial data.
  21408. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21409. * @param scene defines the hosting scene
  21410. * @returns a new MultiMaterial
  21411. */
  21412. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21413. }
  21414. }
  21415. declare module BABYLON {
  21416. /**
  21417. * Base class for submeshes
  21418. */
  21419. export class BaseSubMesh {
  21420. /** @hidden */
  21421. _materialDefines: Nullable<MaterialDefines>;
  21422. /** @hidden */
  21423. _materialEffect: Nullable<Effect>;
  21424. /**
  21425. * Gets material defines used by the effect associated to the sub mesh
  21426. */
  21427. get materialDefines(): Nullable<MaterialDefines>;
  21428. /**
  21429. * Sets material defines used by the effect associated to the sub mesh
  21430. */
  21431. set materialDefines(defines: Nullable<MaterialDefines>);
  21432. /**
  21433. * Gets associated effect
  21434. */
  21435. get effect(): Nullable<Effect>;
  21436. /**
  21437. * Sets associated effect (effect used to render this submesh)
  21438. * @param effect defines the effect to associate with
  21439. * @param defines defines the set of defines used to compile this effect
  21440. */
  21441. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21442. }
  21443. /**
  21444. * Defines a subdivision inside a mesh
  21445. */
  21446. export class SubMesh extends BaseSubMesh implements ICullable {
  21447. /** the material index to use */
  21448. materialIndex: number;
  21449. /** vertex index start */
  21450. verticesStart: number;
  21451. /** vertices count */
  21452. verticesCount: number;
  21453. /** index start */
  21454. indexStart: number;
  21455. /** indices count */
  21456. indexCount: number;
  21457. /** @hidden */
  21458. _linesIndexCount: number;
  21459. private _mesh;
  21460. private _renderingMesh;
  21461. private _boundingInfo;
  21462. private _linesIndexBuffer;
  21463. /** @hidden */
  21464. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21465. /** @hidden */
  21466. _trianglePlanes: Plane[];
  21467. /** @hidden */
  21468. _lastColliderTransformMatrix: Nullable<Matrix>;
  21469. /** @hidden */
  21470. _renderId: number;
  21471. /** @hidden */
  21472. _alphaIndex: number;
  21473. /** @hidden */
  21474. _distanceToCamera: number;
  21475. /** @hidden */
  21476. _id: number;
  21477. private _currentMaterial;
  21478. /**
  21479. * Add a new submesh to a mesh
  21480. * @param materialIndex defines the material index to use
  21481. * @param verticesStart defines vertex index start
  21482. * @param verticesCount defines vertices count
  21483. * @param indexStart defines index start
  21484. * @param indexCount defines indices count
  21485. * @param mesh defines the parent mesh
  21486. * @param renderingMesh defines an optional rendering mesh
  21487. * @param createBoundingBox defines if bounding box should be created for this submesh
  21488. * @returns the new submesh
  21489. */
  21490. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21491. /**
  21492. * Creates a new submesh
  21493. * @param materialIndex defines the material index to use
  21494. * @param verticesStart defines vertex index start
  21495. * @param verticesCount defines vertices count
  21496. * @param indexStart defines index start
  21497. * @param indexCount defines indices count
  21498. * @param mesh defines the parent mesh
  21499. * @param renderingMesh defines an optional rendering mesh
  21500. * @param createBoundingBox defines if bounding box should be created for this submesh
  21501. */
  21502. constructor(
  21503. /** the material index to use */
  21504. materialIndex: number,
  21505. /** vertex index start */
  21506. verticesStart: number,
  21507. /** vertices count */
  21508. verticesCount: number,
  21509. /** index start */
  21510. indexStart: number,
  21511. /** indices count */
  21512. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21513. /**
  21514. * Returns true if this submesh covers the entire parent mesh
  21515. * @ignorenaming
  21516. */
  21517. get IsGlobal(): boolean;
  21518. /**
  21519. * Returns the submesh BoudingInfo object
  21520. * @returns current bounding info (or mesh's one if the submesh is global)
  21521. */
  21522. getBoundingInfo(): BoundingInfo;
  21523. /**
  21524. * Sets the submesh BoundingInfo
  21525. * @param boundingInfo defines the new bounding info to use
  21526. * @returns the SubMesh
  21527. */
  21528. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21529. /**
  21530. * Returns the mesh of the current submesh
  21531. * @return the parent mesh
  21532. */
  21533. getMesh(): AbstractMesh;
  21534. /**
  21535. * Returns the rendering mesh of the submesh
  21536. * @returns the rendering mesh (could be different from parent mesh)
  21537. */
  21538. getRenderingMesh(): Mesh;
  21539. /**
  21540. * Returns the submesh material
  21541. * @returns null or the current material
  21542. */
  21543. getMaterial(): Nullable<Material>;
  21544. /**
  21545. * Sets a new updated BoundingInfo object to the submesh
  21546. * @param data defines an optional position array to use to determine the bounding info
  21547. * @returns the SubMesh
  21548. */
  21549. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21550. /** @hidden */
  21551. _checkCollision(collider: Collider): boolean;
  21552. /**
  21553. * Updates the submesh BoundingInfo
  21554. * @param world defines the world matrix to use to update the bounding info
  21555. * @returns the submesh
  21556. */
  21557. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21558. /**
  21559. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21560. * @param frustumPlanes defines the frustum planes
  21561. * @returns true if the submesh is intersecting with the frustum
  21562. */
  21563. isInFrustum(frustumPlanes: Plane[]): boolean;
  21564. /**
  21565. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21566. * @param frustumPlanes defines the frustum planes
  21567. * @returns true if the submesh is inside the frustum
  21568. */
  21569. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21570. /**
  21571. * Renders the submesh
  21572. * @param enableAlphaMode defines if alpha needs to be used
  21573. * @returns the submesh
  21574. */
  21575. render(enableAlphaMode: boolean): SubMesh;
  21576. /**
  21577. * @hidden
  21578. */
  21579. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21580. /**
  21581. * Checks if the submesh intersects with a ray
  21582. * @param ray defines the ray to test
  21583. * @returns true is the passed ray intersects the submesh bounding box
  21584. */
  21585. canIntersects(ray: Ray): boolean;
  21586. /**
  21587. * Intersects current submesh with a ray
  21588. * @param ray defines the ray to test
  21589. * @param positions defines mesh's positions array
  21590. * @param indices defines mesh's indices array
  21591. * @param fastCheck defines if only bounding info should be used
  21592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21593. * @returns intersection info or null if no intersection
  21594. */
  21595. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21596. /** @hidden */
  21597. private _intersectLines;
  21598. /** @hidden */
  21599. private _intersectUnIndexedLines;
  21600. /** @hidden */
  21601. private _intersectTriangles;
  21602. /** @hidden */
  21603. private _intersectUnIndexedTriangles;
  21604. /** @hidden */
  21605. _rebuild(): void;
  21606. /**
  21607. * Creates a new submesh from the passed mesh
  21608. * @param newMesh defines the new hosting mesh
  21609. * @param newRenderingMesh defines an optional rendering mesh
  21610. * @returns the new submesh
  21611. */
  21612. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21613. /**
  21614. * Release associated resources
  21615. */
  21616. dispose(): void;
  21617. /**
  21618. * Gets the class name
  21619. * @returns the string "SubMesh".
  21620. */
  21621. getClassName(): string;
  21622. /**
  21623. * Creates a new submesh from indices data
  21624. * @param materialIndex the index of the main mesh material
  21625. * @param startIndex the index where to start the copy in the mesh indices array
  21626. * @param indexCount the number of indices to copy then from the startIndex
  21627. * @param mesh the main mesh to create the submesh from
  21628. * @param renderingMesh the optional rendering mesh
  21629. * @returns a new submesh
  21630. */
  21631. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21632. }
  21633. }
  21634. declare module BABYLON {
  21635. /**
  21636. * Class used to represent data loading progression
  21637. */
  21638. export class SceneLoaderFlags {
  21639. private static _ForceFullSceneLoadingForIncremental;
  21640. private static _ShowLoadingScreen;
  21641. private static _CleanBoneMatrixWeights;
  21642. private static _loggingLevel;
  21643. /**
  21644. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21645. */
  21646. static get ForceFullSceneLoadingForIncremental(): boolean;
  21647. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21648. /**
  21649. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21650. */
  21651. static get ShowLoadingScreen(): boolean;
  21652. static set ShowLoadingScreen(value: boolean);
  21653. /**
  21654. * Defines the current logging level (while loading the scene)
  21655. * @ignorenaming
  21656. */
  21657. static get loggingLevel(): number;
  21658. static set loggingLevel(value: number);
  21659. /**
  21660. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21661. */
  21662. static get CleanBoneMatrixWeights(): boolean;
  21663. static set CleanBoneMatrixWeights(value: boolean);
  21664. }
  21665. }
  21666. declare module BABYLON {
  21667. /**
  21668. * Class used to store geometry data (vertex buffers + index buffer)
  21669. */
  21670. export class Geometry implements IGetSetVerticesData {
  21671. /**
  21672. * Gets or sets the ID of the geometry
  21673. */
  21674. id: string;
  21675. /**
  21676. * Gets or sets the unique ID of the geometry
  21677. */
  21678. uniqueId: number;
  21679. /**
  21680. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21681. */
  21682. delayLoadState: number;
  21683. /**
  21684. * Gets the file containing the data to load when running in delay load state
  21685. */
  21686. delayLoadingFile: Nullable<string>;
  21687. /**
  21688. * Callback called when the geometry is updated
  21689. */
  21690. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21691. private _scene;
  21692. private _engine;
  21693. private _meshes;
  21694. private _totalVertices;
  21695. /** @hidden */
  21696. _indices: IndicesArray;
  21697. /** @hidden */
  21698. _vertexBuffers: {
  21699. [key: string]: VertexBuffer;
  21700. };
  21701. private _isDisposed;
  21702. private _extend;
  21703. private _boundingBias;
  21704. /** @hidden */
  21705. _delayInfo: Array<string>;
  21706. private _indexBuffer;
  21707. private _indexBufferIsUpdatable;
  21708. /** @hidden */
  21709. _boundingInfo: Nullable<BoundingInfo>;
  21710. /** @hidden */
  21711. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21712. /** @hidden */
  21713. _softwareSkinningFrameId: number;
  21714. private _vertexArrayObjects;
  21715. private _updatable;
  21716. /** @hidden */
  21717. _positions: Nullable<Vector3[]>;
  21718. /**
  21719. * 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
  21720. */
  21721. get boundingBias(): Vector2;
  21722. /**
  21723. * 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
  21724. */
  21725. set boundingBias(value: Vector2);
  21726. /**
  21727. * Static function used to attach a new empty geometry to a mesh
  21728. * @param mesh defines the mesh to attach the geometry to
  21729. * @returns the new Geometry
  21730. */
  21731. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21732. /**
  21733. * Creates a new geometry
  21734. * @param id defines the unique ID
  21735. * @param scene defines the hosting scene
  21736. * @param vertexData defines the VertexData used to get geometry data
  21737. * @param updatable defines if geometry must be updatable (false by default)
  21738. * @param mesh defines the mesh that will be associated with the geometry
  21739. */
  21740. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21741. /**
  21742. * Gets the current extend of the geometry
  21743. */
  21744. get extend(): {
  21745. minimum: Vector3;
  21746. maximum: Vector3;
  21747. };
  21748. /**
  21749. * Gets the hosting scene
  21750. * @returns the hosting Scene
  21751. */
  21752. getScene(): Scene;
  21753. /**
  21754. * Gets the hosting engine
  21755. * @returns the hosting Engine
  21756. */
  21757. getEngine(): Engine;
  21758. /**
  21759. * Defines if the geometry is ready to use
  21760. * @returns true if the geometry is ready to be used
  21761. */
  21762. isReady(): boolean;
  21763. /**
  21764. * Gets a value indicating that the geometry should not be serialized
  21765. */
  21766. get doNotSerialize(): boolean;
  21767. /** @hidden */
  21768. _rebuild(): void;
  21769. /**
  21770. * Affects all geometry data in one call
  21771. * @param vertexData defines the geometry data
  21772. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21773. */
  21774. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21775. /**
  21776. * Set specific vertex data
  21777. * @param kind defines the data kind (Position, normal, etc...)
  21778. * @param data defines the vertex data to use
  21779. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21780. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21781. */
  21782. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21783. /**
  21784. * Removes a specific vertex data
  21785. * @param kind defines the data kind (Position, normal, etc...)
  21786. */
  21787. removeVerticesData(kind: string): void;
  21788. /**
  21789. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21790. * @param buffer defines the vertex buffer to use
  21791. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21792. */
  21793. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21794. /**
  21795. * Update a specific vertex buffer
  21796. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21797. * It will do nothing if the buffer is not updatable
  21798. * @param kind defines the data kind (Position, normal, etc...)
  21799. * @param data defines the data to use
  21800. * @param offset defines the offset in the target buffer where to store the data
  21801. * @param useBytes set to true if the offset is in bytes
  21802. */
  21803. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21804. /**
  21805. * Update a specific vertex buffer
  21806. * This function will create a new buffer if the current one is not updatable
  21807. * @param kind defines the data kind (Position, normal, etc...)
  21808. * @param data defines the data to use
  21809. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21810. */
  21811. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21812. private _updateBoundingInfo;
  21813. /** @hidden */
  21814. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21815. /**
  21816. * Gets total number of vertices
  21817. * @returns the total number of vertices
  21818. */
  21819. getTotalVertices(): number;
  21820. /**
  21821. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21822. * @param kind defines the data kind (Position, normal, etc...)
  21823. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21824. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21825. * @returns a float array containing vertex data
  21826. */
  21827. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21828. /**
  21829. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21830. * @param kind defines the data kind (Position, normal, etc...)
  21831. * @returns true if the vertex buffer with the specified kind is updatable
  21832. */
  21833. isVertexBufferUpdatable(kind: string): boolean;
  21834. /**
  21835. * Gets a specific vertex buffer
  21836. * @param kind defines the data kind (Position, normal, etc...)
  21837. * @returns a VertexBuffer
  21838. */
  21839. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21840. /**
  21841. * Returns all vertex buffers
  21842. * @return an object holding all vertex buffers indexed by kind
  21843. */
  21844. getVertexBuffers(): Nullable<{
  21845. [key: string]: VertexBuffer;
  21846. }>;
  21847. /**
  21848. * Gets a boolean indicating if specific vertex buffer is present
  21849. * @param kind defines the data kind (Position, normal, etc...)
  21850. * @returns true if data is present
  21851. */
  21852. isVerticesDataPresent(kind: string): boolean;
  21853. /**
  21854. * Gets a list of all attached data kinds (Position, normal, etc...)
  21855. * @returns a list of string containing all kinds
  21856. */
  21857. getVerticesDataKinds(): string[];
  21858. /**
  21859. * Update index buffer
  21860. * @param indices defines the indices to store in the index buffer
  21861. * @param offset defines the offset in the target buffer where to store the data
  21862. * @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)
  21863. */
  21864. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21865. /**
  21866. * Creates a new index buffer
  21867. * @param indices defines the indices to store in the index buffer
  21868. * @param totalVertices defines the total number of vertices (could be null)
  21869. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21870. */
  21871. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21872. /**
  21873. * Return the total number of indices
  21874. * @returns the total number of indices
  21875. */
  21876. getTotalIndices(): number;
  21877. /**
  21878. * Gets the index buffer array
  21879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21881. * @returns the index buffer array
  21882. */
  21883. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21884. /**
  21885. * Gets the index buffer
  21886. * @return the index buffer
  21887. */
  21888. getIndexBuffer(): Nullable<DataBuffer>;
  21889. /** @hidden */
  21890. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21891. /**
  21892. * Release the associated resources for a specific mesh
  21893. * @param mesh defines the source mesh
  21894. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21895. */
  21896. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21897. /**
  21898. * Apply current geometry to a given mesh
  21899. * @param mesh defines the mesh to apply geometry to
  21900. */
  21901. applyToMesh(mesh: Mesh): void;
  21902. private _updateExtend;
  21903. private _applyToMesh;
  21904. private notifyUpdate;
  21905. /**
  21906. * Load the geometry if it was flagged as delay loaded
  21907. * @param scene defines the hosting scene
  21908. * @param onLoaded defines a callback called when the geometry is loaded
  21909. */
  21910. load(scene: Scene, onLoaded?: () => void): void;
  21911. private _queueLoad;
  21912. /**
  21913. * Invert the geometry to move from a right handed system to a left handed one.
  21914. */
  21915. toLeftHanded(): void;
  21916. /** @hidden */
  21917. _resetPointsArrayCache(): void;
  21918. /** @hidden */
  21919. _generatePointsArray(): boolean;
  21920. /**
  21921. * Gets a value indicating if the geometry is disposed
  21922. * @returns true if the geometry was disposed
  21923. */
  21924. isDisposed(): boolean;
  21925. private _disposeVertexArrayObjects;
  21926. /**
  21927. * Free all associated resources
  21928. */
  21929. dispose(): void;
  21930. /**
  21931. * Clone the current geometry into a new geometry
  21932. * @param id defines the unique ID of the new geometry
  21933. * @returns a new geometry object
  21934. */
  21935. copy(id: string): Geometry;
  21936. /**
  21937. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21938. * @return a JSON representation of the current geometry data (without the vertices data)
  21939. */
  21940. serialize(): any;
  21941. private toNumberArray;
  21942. /**
  21943. * Serialize all vertices data into a JSON oject
  21944. * @returns a JSON representation of the current geometry data
  21945. */
  21946. serializeVerticeData(): any;
  21947. /**
  21948. * Extracts a clone of a mesh geometry
  21949. * @param mesh defines the source mesh
  21950. * @param id defines the unique ID of the new geometry object
  21951. * @returns the new geometry object
  21952. */
  21953. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21954. /**
  21955. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21956. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21957. * Be aware Math.random() could cause collisions, but:
  21958. * "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"
  21959. * @returns a string containing a new GUID
  21960. */
  21961. static RandomId(): string;
  21962. /** @hidden */
  21963. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21964. private static _CleanMatricesWeights;
  21965. /**
  21966. * Create a new geometry from persisted data (Using .babylon file format)
  21967. * @param parsedVertexData defines the persisted data
  21968. * @param scene defines the hosting scene
  21969. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21970. * @returns the new geometry object
  21971. */
  21972. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21973. }
  21974. }
  21975. declare module BABYLON {
  21976. /**
  21977. * Define an interface for all classes that will get and set the data on vertices
  21978. */
  21979. export interface IGetSetVerticesData {
  21980. /**
  21981. * Gets a boolean indicating if specific vertex data is present
  21982. * @param kind defines the vertex data kind to use
  21983. * @returns true is data kind is present
  21984. */
  21985. isVerticesDataPresent(kind: string): boolean;
  21986. /**
  21987. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21988. * @param kind defines the data kind (Position, normal, etc...)
  21989. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21990. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21991. * @returns a float array containing vertex data
  21992. */
  21993. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21994. /**
  21995. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21996. * @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.
  21997. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21998. * @returns the indices array or an empty array if the mesh has no geometry
  21999. */
  22000. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22001. /**
  22002. * Set specific vertex data
  22003. * @param kind defines the data kind (Position, normal, etc...)
  22004. * @param data defines the vertex data to use
  22005. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22006. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22007. */
  22008. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22009. /**
  22010. * Update a specific associated vertex buffer
  22011. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22012. * - VertexBuffer.PositionKind
  22013. * - VertexBuffer.UVKind
  22014. * - VertexBuffer.UV2Kind
  22015. * - VertexBuffer.UV3Kind
  22016. * - VertexBuffer.UV4Kind
  22017. * - VertexBuffer.UV5Kind
  22018. * - VertexBuffer.UV6Kind
  22019. * - VertexBuffer.ColorKind
  22020. * - VertexBuffer.MatricesIndicesKind
  22021. * - VertexBuffer.MatricesIndicesExtraKind
  22022. * - VertexBuffer.MatricesWeightsKind
  22023. * - VertexBuffer.MatricesWeightsExtraKind
  22024. * @param data defines the data source
  22025. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22026. * @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)
  22027. */
  22028. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22029. /**
  22030. * Creates a new index buffer
  22031. * @param indices defines the indices to store in the index buffer
  22032. * @param totalVertices defines the total number of vertices (could be null)
  22033. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22034. */
  22035. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22036. }
  22037. /**
  22038. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22039. */
  22040. export class VertexData {
  22041. /**
  22042. * Mesh side orientation : usually the external or front surface
  22043. */
  22044. static readonly FRONTSIDE: number;
  22045. /**
  22046. * Mesh side orientation : usually the internal or back surface
  22047. */
  22048. static readonly BACKSIDE: number;
  22049. /**
  22050. * Mesh side orientation : both internal and external or front and back surfaces
  22051. */
  22052. static readonly DOUBLESIDE: number;
  22053. /**
  22054. * Mesh side orientation : by default, `FRONTSIDE`
  22055. */
  22056. static readonly DEFAULTSIDE: number;
  22057. /**
  22058. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22059. */
  22060. positions: Nullable<FloatArray>;
  22061. /**
  22062. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22063. */
  22064. normals: Nullable<FloatArray>;
  22065. /**
  22066. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22067. */
  22068. tangents: Nullable<FloatArray>;
  22069. /**
  22070. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22071. */
  22072. uvs: Nullable<FloatArray>;
  22073. /**
  22074. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22075. */
  22076. uvs2: Nullable<FloatArray>;
  22077. /**
  22078. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22079. */
  22080. uvs3: Nullable<FloatArray>;
  22081. /**
  22082. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22083. */
  22084. uvs4: Nullable<FloatArray>;
  22085. /**
  22086. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22087. */
  22088. uvs5: Nullable<FloatArray>;
  22089. /**
  22090. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22091. */
  22092. uvs6: Nullable<FloatArray>;
  22093. /**
  22094. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22095. */
  22096. colors: Nullable<FloatArray>;
  22097. /**
  22098. * 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).
  22099. */
  22100. matricesIndices: Nullable<FloatArray>;
  22101. /**
  22102. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22103. */
  22104. matricesWeights: Nullable<FloatArray>;
  22105. /**
  22106. * An array extending the number of possible indices
  22107. */
  22108. matricesIndicesExtra: Nullable<FloatArray>;
  22109. /**
  22110. * An array extending the number of possible weights when the number of indices is extended
  22111. */
  22112. matricesWeightsExtra: Nullable<FloatArray>;
  22113. /**
  22114. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22115. */
  22116. indices: Nullable<IndicesArray>;
  22117. /**
  22118. * Uses the passed data array to set the set the values for the specified kind of data
  22119. * @param data a linear array of floating numbers
  22120. * @param kind the type of data that is being set, eg positions, colors etc
  22121. */
  22122. set(data: FloatArray, kind: string): void;
  22123. /**
  22124. * Associates the vertexData to the passed Mesh.
  22125. * Sets it as updatable or not (default `false`)
  22126. * @param mesh the mesh the vertexData is applied to
  22127. * @param updatable when used and having the value true allows new data to update the vertexData
  22128. * @returns the VertexData
  22129. */
  22130. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22131. /**
  22132. * Associates the vertexData to the passed Geometry.
  22133. * Sets it as updatable or not (default `false`)
  22134. * @param geometry the geometry the vertexData is applied to
  22135. * @param updatable when used and having the value true allows new data to update the vertexData
  22136. * @returns VertexData
  22137. */
  22138. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22139. /**
  22140. * Updates the associated mesh
  22141. * @param mesh the mesh to be updated
  22142. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22143. * @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
  22144. * @returns VertexData
  22145. */
  22146. updateMesh(mesh: Mesh): VertexData;
  22147. /**
  22148. * Updates the associated geometry
  22149. * @param geometry the geometry to be updated
  22150. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22151. * @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
  22152. * @returns VertexData.
  22153. */
  22154. updateGeometry(geometry: Geometry): VertexData;
  22155. private _applyTo;
  22156. private _update;
  22157. /**
  22158. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22159. * @param matrix the transforming matrix
  22160. * @returns the VertexData
  22161. */
  22162. transform(matrix: Matrix): VertexData;
  22163. /**
  22164. * Merges the passed VertexData into the current one
  22165. * @param other the VertexData to be merged into the current one
  22166. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22167. * @returns the modified VertexData
  22168. */
  22169. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22170. private _mergeElement;
  22171. private _validate;
  22172. /**
  22173. * Serializes the VertexData
  22174. * @returns a serialized object
  22175. */
  22176. serialize(): any;
  22177. /**
  22178. * Extracts the vertexData from a mesh
  22179. * @param mesh the mesh from which to extract the VertexData
  22180. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22182. * @returns the object VertexData associated to the passed mesh
  22183. */
  22184. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22185. /**
  22186. * Extracts the vertexData from the geometry
  22187. * @param geometry the geometry from which to extract the VertexData
  22188. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22189. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22190. * @returns the object VertexData associated to the passed mesh
  22191. */
  22192. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22193. private static _ExtractFrom;
  22194. /**
  22195. * Creates the VertexData for a Ribbon
  22196. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22197. * * pathArray array of paths, each of which an array of successive Vector3
  22198. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22199. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22200. * * 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
  22201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22202. * * 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)
  22203. * * 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)
  22204. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22205. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22206. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22207. * @returns the VertexData of the ribbon
  22208. */
  22209. static CreateRibbon(options: {
  22210. pathArray: Vector3[][];
  22211. closeArray?: boolean;
  22212. closePath?: boolean;
  22213. offset?: number;
  22214. sideOrientation?: number;
  22215. frontUVs?: Vector4;
  22216. backUVs?: Vector4;
  22217. invertUV?: boolean;
  22218. uvs?: Vector2[];
  22219. colors?: Color4[];
  22220. }): VertexData;
  22221. /**
  22222. * Creates the VertexData for a box
  22223. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22224. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22225. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22226. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22227. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22228. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22229. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22230. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22231. * * 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)
  22232. * * 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)
  22233. * @returns the VertexData of the box
  22234. */
  22235. static CreateBox(options: {
  22236. size?: number;
  22237. width?: number;
  22238. height?: number;
  22239. depth?: number;
  22240. faceUV?: Vector4[];
  22241. faceColors?: Color4[];
  22242. sideOrientation?: number;
  22243. frontUVs?: Vector4;
  22244. backUVs?: Vector4;
  22245. }): VertexData;
  22246. /**
  22247. * Creates the VertexData for a tiled box
  22248. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22249. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22250. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22251. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22252. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22253. * @returns the VertexData of the box
  22254. */
  22255. static CreateTiledBox(options: {
  22256. pattern?: number;
  22257. width?: number;
  22258. height?: number;
  22259. depth?: number;
  22260. tileSize?: number;
  22261. tileWidth?: number;
  22262. tileHeight?: number;
  22263. alignHorizontal?: number;
  22264. alignVertical?: number;
  22265. faceUV?: Vector4[];
  22266. faceColors?: Color4[];
  22267. sideOrientation?: number;
  22268. }): VertexData;
  22269. /**
  22270. * Creates the VertexData for a tiled plane
  22271. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22272. * * pattern a limited pattern arrangement depending on the number
  22273. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22274. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22275. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22276. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22277. * * 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)
  22278. * * 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)
  22279. * @returns the VertexData of the tiled plane
  22280. */
  22281. static CreateTiledPlane(options: {
  22282. pattern?: number;
  22283. tileSize?: number;
  22284. tileWidth?: number;
  22285. tileHeight?: number;
  22286. size?: number;
  22287. width?: number;
  22288. height?: number;
  22289. alignHorizontal?: number;
  22290. alignVertical?: number;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. }): VertexData;
  22295. /**
  22296. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22298. * * segments sets the number of horizontal strips optional, default 32
  22299. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22300. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22301. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22302. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22303. * * 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
  22304. * * 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
  22305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22306. * * 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)
  22307. * * 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)
  22308. * @returns the VertexData of the ellipsoid
  22309. */
  22310. static CreateSphere(options: {
  22311. segments?: number;
  22312. diameter?: number;
  22313. diameterX?: number;
  22314. diameterY?: number;
  22315. diameterZ?: number;
  22316. arc?: number;
  22317. slice?: number;
  22318. sideOrientation?: number;
  22319. frontUVs?: Vector4;
  22320. backUVs?: Vector4;
  22321. }): VertexData;
  22322. /**
  22323. * Creates the VertexData for a cylinder, cone or prism
  22324. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22325. * * height sets the height (y direction) of the cylinder, optional, default 2
  22326. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22327. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22328. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22329. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22330. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22331. * * 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
  22332. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22333. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22334. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22335. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22336. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22337. * * 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)
  22338. * * 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)
  22339. * @returns the VertexData of the cylinder, cone or prism
  22340. */
  22341. static CreateCylinder(options: {
  22342. height?: number;
  22343. diameterTop?: number;
  22344. diameterBottom?: number;
  22345. diameter?: number;
  22346. tessellation?: number;
  22347. subdivisions?: number;
  22348. arc?: number;
  22349. faceColors?: Color4[];
  22350. faceUV?: Vector4[];
  22351. hasRings?: boolean;
  22352. enclose?: boolean;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData for a torus
  22359. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22360. * * diameter the diameter of the torus, optional default 1
  22361. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22362. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22364. * * 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)
  22365. * * 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)
  22366. * @returns the VertexData of the torus
  22367. */
  22368. static CreateTorus(options: {
  22369. diameter?: number;
  22370. thickness?: number;
  22371. tessellation?: number;
  22372. sideOrientation?: number;
  22373. frontUVs?: Vector4;
  22374. backUVs?: Vector4;
  22375. }): VertexData;
  22376. /**
  22377. * Creates the VertexData of the LineSystem
  22378. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22379. * - lines an array of lines, each line being an array of successive Vector3
  22380. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22381. * @returns the VertexData of the LineSystem
  22382. */
  22383. static CreateLineSystem(options: {
  22384. lines: Vector3[][];
  22385. colors?: Nullable<Color4[][]>;
  22386. }): VertexData;
  22387. /**
  22388. * Create the VertexData for a DashedLines
  22389. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22390. * - points an array successive Vector3
  22391. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22392. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22393. * - dashNb the intended total number of dashes, optional, default 200
  22394. * @returns the VertexData for the DashedLines
  22395. */
  22396. static CreateDashedLines(options: {
  22397. points: Vector3[];
  22398. dashSize?: number;
  22399. gapSize?: number;
  22400. dashNb?: number;
  22401. }): VertexData;
  22402. /**
  22403. * Creates the VertexData for a Ground
  22404. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22405. * - width the width (x direction) of the ground, optional, default 1
  22406. * - height the height (z direction) of the ground, optional, default 1
  22407. * - subdivisions the number of subdivisions per side, optional, default 1
  22408. * @returns the VertexData of the Ground
  22409. */
  22410. static CreateGround(options: {
  22411. width?: number;
  22412. height?: number;
  22413. subdivisions?: number;
  22414. subdivisionsX?: number;
  22415. subdivisionsY?: number;
  22416. }): VertexData;
  22417. /**
  22418. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22419. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22420. * * xmin the ground minimum X coordinate, optional, default -1
  22421. * * zmin the ground minimum Z coordinate, optional, default -1
  22422. * * xmax the ground maximum X coordinate, optional, default 1
  22423. * * zmax the ground maximum Z coordinate, optional, default 1
  22424. * * 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}
  22425. * * 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}
  22426. * @returns the VertexData of the TiledGround
  22427. */
  22428. static CreateTiledGround(options: {
  22429. xmin: number;
  22430. zmin: number;
  22431. xmax: number;
  22432. zmax: number;
  22433. subdivisions?: {
  22434. w: number;
  22435. h: number;
  22436. };
  22437. precision?: {
  22438. w: number;
  22439. h: number;
  22440. };
  22441. }): VertexData;
  22442. /**
  22443. * Creates the VertexData of the Ground designed from a heightmap
  22444. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22445. * * width the width (x direction) of the ground
  22446. * * height the height (z direction) of the ground
  22447. * * subdivisions the number of subdivisions per side
  22448. * * minHeight the minimum altitude on the ground, optional, default 0
  22449. * * maxHeight the maximum altitude on the ground, optional default 1
  22450. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22451. * * buffer the array holding the image color data
  22452. * * bufferWidth the width of image
  22453. * * bufferHeight the height of image
  22454. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22455. * @returns the VertexData of the Ground designed from a heightmap
  22456. */
  22457. static CreateGroundFromHeightMap(options: {
  22458. width: number;
  22459. height: number;
  22460. subdivisions: number;
  22461. minHeight: number;
  22462. maxHeight: number;
  22463. colorFilter: Color3;
  22464. buffer: Uint8Array;
  22465. bufferWidth: number;
  22466. bufferHeight: number;
  22467. alphaFilter: number;
  22468. }): VertexData;
  22469. /**
  22470. * Creates the VertexData for a Plane
  22471. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22472. * * size sets the width and height of the plane to the value of size, optional default 1
  22473. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22474. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22475. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22476. * * 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)
  22477. * * 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)
  22478. * @returns the VertexData of the box
  22479. */
  22480. static CreatePlane(options: {
  22481. size?: number;
  22482. width?: number;
  22483. height?: number;
  22484. sideOrientation?: number;
  22485. frontUVs?: Vector4;
  22486. backUVs?: Vector4;
  22487. }): VertexData;
  22488. /**
  22489. * Creates the VertexData of the Disc or regular Polygon
  22490. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22491. * * radius the radius of the disc, optional default 0.5
  22492. * * tessellation the number of polygon sides, optional, default 64
  22493. * * 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
  22494. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22495. * * 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)
  22496. * * 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)
  22497. * @returns the VertexData of the box
  22498. */
  22499. static CreateDisc(options: {
  22500. radius?: number;
  22501. tessellation?: number;
  22502. arc?: number;
  22503. sideOrientation?: number;
  22504. frontUVs?: Vector4;
  22505. backUVs?: Vector4;
  22506. }): VertexData;
  22507. /**
  22508. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22509. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22510. * @param polygon a mesh built from polygonTriangulation.build()
  22511. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22512. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22513. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22514. * @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)
  22515. * @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)
  22516. * @returns the VertexData of the Polygon
  22517. */
  22518. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22519. /**
  22520. * Creates the VertexData of the IcoSphere
  22521. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22522. * * radius the radius of the IcoSphere, optional default 1
  22523. * * radiusX allows stretching in the x direction, optional, default radius
  22524. * * radiusY allows stretching in the y direction, optional, default radius
  22525. * * radiusZ allows stretching in the z direction, optional, default radius
  22526. * * flat when true creates a flat shaded mesh, optional, default true
  22527. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22528. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22529. * * 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)
  22530. * * 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)
  22531. * @returns the VertexData of the IcoSphere
  22532. */
  22533. static CreateIcoSphere(options: {
  22534. radius?: number;
  22535. radiusX?: number;
  22536. radiusY?: number;
  22537. radiusZ?: number;
  22538. flat?: boolean;
  22539. subdivisions?: number;
  22540. sideOrientation?: number;
  22541. frontUVs?: Vector4;
  22542. backUVs?: Vector4;
  22543. }): VertexData;
  22544. /**
  22545. * Creates the VertexData for a Polyhedron
  22546. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22547. * * type provided types are:
  22548. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22549. * * 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)
  22550. * * size the size of the IcoSphere, optional default 1
  22551. * * sizeX allows stretching in the x direction, optional, default size
  22552. * * sizeY allows stretching in the y direction, optional, default size
  22553. * * sizeZ allows stretching in the z direction, optional, default size
  22554. * * 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
  22555. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22556. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22557. * * flat when true creates a flat shaded mesh, optional, default true
  22558. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22559. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22560. * * 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)
  22561. * * 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)
  22562. * @returns the VertexData of the Polyhedron
  22563. */
  22564. static CreatePolyhedron(options: {
  22565. type?: number;
  22566. size?: number;
  22567. sizeX?: number;
  22568. sizeY?: number;
  22569. sizeZ?: number;
  22570. custom?: any;
  22571. faceUV?: Vector4[];
  22572. faceColors?: Color4[];
  22573. flat?: boolean;
  22574. sideOrientation?: number;
  22575. frontUVs?: Vector4;
  22576. backUVs?: Vector4;
  22577. }): VertexData;
  22578. /**
  22579. * Creates the VertexData for a TorusKnot
  22580. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22581. * * radius the radius of the torus knot, optional, default 2
  22582. * * tube the thickness of the tube, optional, default 0.5
  22583. * * radialSegments the number of sides on each tube segments, optional, default 32
  22584. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22585. * * p the number of windings around the z axis, optional, default 2
  22586. * * q the number of windings around the x axis, optional, default 3
  22587. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22588. * * 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)
  22589. * * 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)
  22590. * @returns the VertexData of the Torus Knot
  22591. */
  22592. static CreateTorusKnot(options: {
  22593. radius?: number;
  22594. tube?: number;
  22595. radialSegments?: number;
  22596. tubularSegments?: number;
  22597. p?: number;
  22598. q?: number;
  22599. sideOrientation?: number;
  22600. frontUVs?: Vector4;
  22601. backUVs?: Vector4;
  22602. }): VertexData;
  22603. /**
  22604. * Compute normals for given positions and indices
  22605. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22606. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22607. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22608. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22609. * * facetNormals : optional array of facet normals (vector3)
  22610. * * facetPositions : optional array of facet positions (vector3)
  22611. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22612. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22613. * * bInfo : optional bounding info, required for facetPartitioning computation
  22614. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22615. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22616. * * useRightHandedSystem: optional boolean to for right handed system computation
  22617. * * depthSort : optional boolean to enable the facet depth sort computation
  22618. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22619. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22620. */
  22621. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22622. facetNormals?: any;
  22623. facetPositions?: any;
  22624. facetPartitioning?: any;
  22625. ratio?: number;
  22626. bInfo?: any;
  22627. bbSize?: Vector3;
  22628. subDiv?: any;
  22629. useRightHandedSystem?: boolean;
  22630. depthSort?: boolean;
  22631. distanceTo?: Vector3;
  22632. depthSortedFacets?: any;
  22633. }): void;
  22634. /** @hidden */
  22635. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22636. /**
  22637. * Applies VertexData created from the imported parameters to the geometry
  22638. * @param parsedVertexData the parsed data from an imported file
  22639. * @param geometry the geometry to apply the VertexData to
  22640. */
  22641. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22642. }
  22643. }
  22644. declare module BABYLON {
  22645. /**
  22646. * Defines a target to use with MorphTargetManager
  22647. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22648. */
  22649. export class MorphTarget implements IAnimatable {
  22650. /** defines the name of the target */
  22651. name: string;
  22652. /**
  22653. * Gets or sets the list of animations
  22654. */
  22655. animations: Animation[];
  22656. private _scene;
  22657. private _positions;
  22658. private _normals;
  22659. private _tangents;
  22660. private _uvs;
  22661. private _influence;
  22662. private _uniqueId;
  22663. /**
  22664. * Observable raised when the influence changes
  22665. */
  22666. onInfluenceChanged: Observable<boolean>;
  22667. /** @hidden */
  22668. _onDataLayoutChanged: Observable<void>;
  22669. /**
  22670. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22671. */
  22672. get influence(): number;
  22673. set influence(influence: number);
  22674. /**
  22675. * Gets or sets the id of the morph Target
  22676. */
  22677. id: string;
  22678. private _animationPropertiesOverride;
  22679. /**
  22680. * Gets or sets the animation properties override
  22681. */
  22682. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22683. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22684. /**
  22685. * Creates a new MorphTarget
  22686. * @param name defines the name of the target
  22687. * @param influence defines the influence to use
  22688. * @param scene defines the scene the morphtarget belongs to
  22689. */
  22690. constructor(
  22691. /** defines the name of the target */
  22692. name: string, influence?: number, scene?: Nullable<Scene>);
  22693. /**
  22694. * Gets the unique ID of this manager
  22695. */
  22696. get uniqueId(): number;
  22697. /**
  22698. * Gets a boolean defining if the target contains position data
  22699. */
  22700. get hasPositions(): boolean;
  22701. /**
  22702. * Gets a boolean defining if the target contains normal data
  22703. */
  22704. get hasNormals(): boolean;
  22705. /**
  22706. * Gets a boolean defining if the target contains tangent data
  22707. */
  22708. get hasTangents(): boolean;
  22709. /**
  22710. * Gets a boolean defining if the target contains texture coordinates data
  22711. */
  22712. get hasUVs(): boolean;
  22713. /**
  22714. * Affects position data to this target
  22715. * @param data defines the position data to use
  22716. */
  22717. setPositions(data: Nullable<FloatArray>): void;
  22718. /**
  22719. * Gets the position data stored in this target
  22720. * @returns a FloatArray containing the position data (or null if not present)
  22721. */
  22722. getPositions(): Nullable<FloatArray>;
  22723. /**
  22724. * Affects normal data to this target
  22725. * @param data defines the normal data to use
  22726. */
  22727. setNormals(data: Nullable<FloatArray>): void;
  22728. /**
  22729. * Gets the normal data stored in this target
  22730. * @returns a FloatArray containing the normal data (or null if not present)
  22731. */
  22732. getNormals(): Nullable<FloatArray>;
  22733. /**
  22734. * Affects tangent data to this target
  22735. * @param data defines the tangent data to use
  22736. */
  22737. setTangents(data: Nullable<FloatArray>): void;
  22738. /**
  22739. * Gets the tangent data stored in this target
  22740. * @returns a FloatArray containing the tangent data (or null if not present)
  22741. */
  22742. getTangents(): Nullable<FloatArray>;
  22743. /**
  22744. * Affects texture coordinates data to this target
  22745. * @param data defines the texture coordinates data to use
  22746. */
  22747. setUVs(data: Nullable<FloatArray>): void;
  22748. /**
  22749. * Gets the texture coordinates data stored in this target
  22750. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22751. */
  22752. getUVs(): Nullable<FloatArray>;
  22753. /**
  22754. * Clone the current target
  22755. * @returns a new MorphTarget
  22756. */
  22757. clone(): MorphTarget;
  22758. /**
  22759. * Serializes the current target into a Serialization object
  22760. * @returns the serialized object
  22761. */
  22762. serialize(): any;
  22763. /**
  22764. * Returns the string "MorphTarget"
  22765. * @returns "MorphTarget"
  22766. */
  22767. getClassName(): string;
  22768. /**
  22769. * Creates a new target from serialized data
  22770. * @param serializationObject defines the serialized data to use
  22771. * @returns a new MorphTarget
  22772. */
  22773. static Parse(serializationObject: any): MorphTarget;
  22774. /**
  22775. * Creates a MorphTarget from mesh data
  22776. * @param mesh defines the source mesh
  22777. * @param name defines the name to use for the new target
  22778. * @param influence defines the influence to attach to the target
  22779. * @returns a new MorphTarget
  22780. */
  22781. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22782. }
  22783. }
  22784. declare module BABYLON {
  22785. /**
  22786. * This class is used to deform meshes using morphing between different targets
  22787. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22788. */
  22789. export class MorphTargetManager {
  22790. private _targets;
  22791. private _targetInfluenceChangedObservers;
  22792. private _targetDataLayoutChangedObservers;
  22793. private _activeTargets;
  22794. private _scene;
  22795. private _influences;
  22796. private _supportsNormals;
  22797. private _supportsTangents;
  22798. private _supportsUVs;
  22799. private _vertexCount;
  22800. private _uniqueId;
  22801. private _tempInfluences;
  22802. /**
  22803. * Gets or sets a boolean indicating if normals must be morphed
  22804. */
  22805. enableNormalMorphing: boolean;
  22806. /**
  22807. * Gets or sets a boolean indicating if tangents must be morphed
  22808. */
  22809. enableTangentMorphing: boolean;
  22810. /**
  22811. * Gets or sets a boolean indicating if UV must be morphed
  22812. */
  22813. enableUVMorphing: boolean;
  22814. /**
  22815. * Creates a new MorphTargetManager
  22816. * @param scene defines the current scene
  22817. */
  22818. constructor(scene?: Nullable<Scene>);
  22819. /**
  22820. * Gets the unique ID of this manager
  22821. */
  22822. get uniqueId(): number;
  22823. /**
  22824. * Gets the number of vertices handled by this manager
  22825. */
  22826. get vertexCount(): number;
  22827. /**
  22828. * Gets a boolean indicating if this manager supports morphing of normals
  22829. */
  22830. get supportsNormals(): boolean;
  22831. /**
  22832. * Gets a boolean indicating if this manager supports morphing of tangents
  22833. */
  22834. get supportsTangents(): boolean;
  22835. /**
  22836. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22837. */
  22838. get supportsUVs(): boolean;
  22839. /**
  22840. * Gets the number of targets stored in this manager
  22841. */
  22842. get numTargets(): number;
  22843. /**
  22844. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22845. */
  22846. get numInfluencers(): number;
  22847. /**
  22848. * Gets the list of influences (one per target)
  22849. */
  22850. get influences(): Float32Array;
  22851. /**
  22852. * Gets the active target at specified index. An active target is a target with an influence > 0
  22853. * @param index defines the index to check
  22854. * @returns the requested target
  22855. */
  22856. getActiveTarget(index: number): MorphTarget;
  22857. /**
  22858. * Gets the target at specified index
  22859. * @param index defines the index to check
  22860. * @returns the requested target
  22861. */
  22862. getTarget(index: number): MorphTarget;
  22863. /**
  22864. * Add a new target to this manager
  22865. * @param target defines the target to add
  22866. */
  22867. addTarget(target: MorphTarget): void;
  22868. /**
  22869. * Removes a target from the manager
  22870. * @param target defines the target to remove
  22871. */
  22872. removeTarget(target: MorphTarget): void;
  22873. /**
  22874. * Clone the current manager
  22875. * @returns a new MorphTargetManager
  22876. */
  22877. clone(): MorphTargetManager;
  22878. /**
  22879. * Serializes the current manager into a Serialization object
  22880. * @returns the serialized object
  22881. */
  22882. serialize(): any;
  22883. private _syncActiveTargets;
  22884. /**
  22885. * Syncrhonize the targets with all the meshes using this morph target manager
  22886. */
  22887. synchronize(): void;
  22888. /**
  22889. * Creates a new MorphTargetManager from serialized data
  22890. * @param serializationObject defines the serialized data
  22891. * @param scene defines the hosting scene
  22892. * @returns the new MorphTargetManager
  22893. */
  22894. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22895. }
  22896. }
  22897. declare module BABYLON {
  22898. /**
  22899. * Class used to represent a specific level of detail of a mesh
  22900. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22901. */
  22902. export class MeshLODLevel {
  22903. /** Defines the distance where this level should start being displayed */
  22904. distance: number;
  22905. /** Defines the mesh to use to render this level */
  22906. mesh: Nullable<Mesh>;
  22907. /**
  22908. * Creates a new LOD level
  22909. * @param distance defines the distance where this level should star being displayed
  22910. * @param mesh defines the mesh to use to render this level
  22911. */
  22912. constructor(
  22913. /** Defines the distance where this level should start being displayed */
  22914. distance: number,
  22915. /** Defines the mesh to use to render this level */
  22916. mesh: Nullable<Mesh>);
  22917. }
  22918. }
  22919. declare module BABYLON {
  22920. /**
  22921. * Mesh representing the gorund
  22922. */
  22923. export class GroundMesh extends Mesh {
  22924. /** If octree should be generated */
  22925. generateOctree: boolean;
  22926. private _heightQuads;
  22927. /** @hidden */
  22928. _subdivisionsX: number;
  22929. /** @hidden */
  22930. _subdivisionsY: number;
  22931. /** @hidden */
  22932. _width: number;
  22933. /** @hidden */
  22934. _height: number;
  22935. /** @hidden */
  22936. _minX: number;
  22937. /** @hidden */
  22938. _maxX: number;
  22939. /** @hidden */
  22940. _minZ: number;
  22941. /** @hidden */
  22942. _maxZ: number;
  22943. constructor(name: string, scene: Scene);
  22944. /**
  22945. * "GroundMesh"
  22946. * @returns "GroundMesh"
  22947. */
  22948. getClassName(): string;
  22949. /**
  22950. * The minimum of x and y subdivisions
  22951. */
  22952. get subdivisions(): number;
  22953. /**
  22954. * X subdivisions
  22955. */
  22956. get subdivisionsX(): number;
  22957. /**
  22958. * Y subdivisions
  22959. */
  22960. get subdivisionsY(): number;
  22961. /**
  22962. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22963. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22964. * @param chunksCount the number of subdivisions for x and y
  22965. * @param octreeBlocksSize (Default: 32)
  22966. */
  22967. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22968. /**
  22969. * Returns a height (y) value in the Worl system :
  22970. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22971. * @param x x coordinate
  22972. * @param z z coordinate
  22973. * @returns the ground y position if (x, z) are outside the ground surface.
  22974. */
  22975. getHeightAtCoordinates(x: number, z: number): number;
  22976. /**
  22977. * Returns a normalized vector (Vector3) orthogonal to the ground
  22978. * at the ground coordinates (x, z) expressed in the World system.
  22979. * @param x x coordinate
  22980. * @param z z coordinate
  22981. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22982. */
  22983. getNormalAtCoordinates(x: number, z: number): Vector3;
  22984. /**
  22985. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22986. * at the ground coordinates (x, z) expressed in the World system.
  22987. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22988. * @param x x coordinate
  22989. * @param z z coordinate
  22990. * @param ref vector to store the result
  22991. * @returns the GroundMesh.
  22992. */
  22993. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22994. /**
  22995. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22996. * if the ground has been updated.
  22997. * This can be used in the render loop.
  22998. * @returns the GroundMesh.
  22999. */
  23000. updateCoordinateHeights(): GroundMesh;
  23001. private _getFacetAt;
  23002. private _initHeightQuads;
  23003. private _computeHeightQuads;
  23004. /**
  23005. * Serializes this ground mesh
  23006. * @param serializationObject object to write serialization to
  23007. */
  23008. serialize(serializationObject: any): void;
  23009. /**
  23010. * Parses a serialized ground mesh
  23011. * @param parsedMesh the serialized mesh
  23012. * @param scene the scene to create the ground mesh in
  23013. * @returns the created ground mesh
  23014. */
  23015. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23016. }
  23017. }
  23018. declare module BABYLON {
  23019. /**
  23020. * Interface for Physics-Joint data
  23021. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23022. */
  23023. export interface PhysicsJointData {
  23024. /**
  23025. * The main pivot of the joint
  23026. */
  23027. mainPivot?: Vector3;
  23028. /**
  23029. * The connected pivot of the joint
  23030. */
  23031. connectedPivot?: Vector3;
  23032. /**
  23033. * The main axis of the joint
  23034. */
  23035. mainAxis?: Vector3;
  23036. /**
  23037. * The connected axis of the joint
  23038. */
  23039. connectedAxis?: Vector3;
  23040. /**
  23041. * The collision of the joint
  23042. */
  23043. collision?: boolean;
  23044. /**
  23045. * Native Oimo/Cannon/Energy data
  23046. */
  23047. nativeParams?: any;
  23048. }
  23049. /**
  23050. * This is a holder class for the physics joint created by the physics plugin
  23051. * It holds a set of functions to control the underlying joint
  23052. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23053. */
  23054. export class PhysicsJoint {
  23055. /**
  23056. * The type of the physics joint
  23057. */
  23058. type: number;
  23059. /**
  23060. * The data for the physics joint
  23061. */
  23062. jointData: PhysicsJointData;
  23063. private _physicsJoint;
  23064. protected _physicsPlugin: IPhysicsEnginePlugin;
  23065. /**
  23066. * Initializes the physics joint
  23067. * @param type The type of the physics joint
  23068. * @param jointData The data for the physics joint
  23069. */
  23070. constructor(
  23071. /**
  23072. * The type of the physics joint
  23073. */
  23074. type: number,
  23075. /**
  23076. * The data for the physics joint
  23077. */
  23078. jointData: PhysicsJointData);
  23079. /**
  23080. * Gets the physics joint
  23081. */
  23082. get physicsJoint(): any;
  23083. /**
  23084. * Sets the physics joint
  23085. */
  23086. set physicsJoint(newJoint: any);
  23087. /**
  23088. * Sets the physics plugin
  23089. */
  23090. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23091. /**
  23092. * Execute a function that is physics-plugin specific.
  23093. * @param {Function} func the function that will be executed.
  23094. * It accepts two parameters: the physics world and the physics joint
  23095. */
  23096. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23097. /**
  23098. * Distance-Joint type
  23099. */
  23100. static DistanceJoint: number;
  23101. /**
  23102. * Hinge-Joint type
  23103. */
  23104. static HingeJoint: number;
  23105. /**
  23106. * Ball-and-Socket joint type
  23107. */
  23108. static BallAndSocketJoint: number;
  23109. /**
  23110. * Wheel-Joint type
  23111. */
  23112. static WheelJoint: number;
  23113. /**
  23114. * Slider-Joint type
  23115. */
  23116. static SliderJoint: number;
  23117. /**
  23118. * Prismatic-Joint type
  23119. */
  23120. static PrismaticJoint: number;
  23121. /**
  23122. * Universal-Joint type
  23123. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23124. */
  23125. static UniversalJoint: number;
  23126. /**
  23127. * Hinge-Joint 2 type
  23128. */
  23129. static Hinge2Joint: number;
  23130. /**
  23131. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23132. */
  23133. static PointToPointJoint: number;
  23134. /**
  23135. * Spring-Joint type
  23136. */
  23137. static SpringJoint: number;
  23138. /**
  23139. * Lock-Joint type
  23140. */
  23141. static LockJoint: number;
  23142. }
  23143. /**
  23144. * A class representing a physics distance joint
  23145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23146. */
  23147. export class DistanceJoint extends PhysicsJoint {
  23148. /**
  23149. *
  23150. * @param jointData The data for the Distance-Joint
  23151. */
  23152. constructor(jointData: DistanceJointData);
  23153. /**
  23154. * Update the predefined distance.
  23155. * @param maxDistance The maximum preferred distance
  23156. * @param minDistance The minimum preferred distance
  23157. */
  23158. updateDistance(maxDistance: number, minDistance?: number): void;
  23159. }
  23160. /**
  23161. * Represents a Motor-Enabled Joint
  23162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23163. */
  23164. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23165. /**
  23166. * Initializes the Motor-Enabled Joint
  23167. * @param type The type of the joint
  23168. * @param jointData The physica joint data for the joint
  23169. */
  23170. constructor(type: number, jointData: PhysicsJointData);
  23171. /**
  23172. * Set the motor values.
  23173. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23174. * @param force the force to apply
  23175. * @param maxForce max force for this motor.
  23176. */
  23177. setMotor(force?: number, maxForce?: number): void;
  23178. /**
  23179. * Set the motor's limits.
  23180. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23181. * @param upperLimit The upper limit of the motor
  23182. * @param lowerLimit The lower limit of the motor
  23183. */
  23184. setLimit(upperLimit: number, lowerLimit?: number): void;
  23185. }
  23186. /**
  23187. * This class represents a single physics Hinge-Joint
  23188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23189. */
  23190. export class HingeJoint extends MotorEnabledJoint {
  23191. /**
  23192. * Initializes the Hinge-Joint
  23193. * @param jointData The joint data for the Hinge-Joint
  23194. */
  23195. constructor(jointData: PhysicsJointData);
  23196. /**
  23197. * Set the motor values.
  23198. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23199. * @param {number} force the force to apply
  23200. * @param {number} maxForce max force for this motor.
  23201. */
  23202. setMotor(force?: number, maxForce?: number): void;
  23203. /**
  23204. * Set the motor's limits.
  23205. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23206. * @param upperLimit The upper limit of the motor
  23207. * @param lowerLimit The lower limit of the motor
  23208. */
  23209. setLimit(upperLimit: number, lowerLimit?: number): void;
  23210. }
  23211. /**
  23212. * This class represents a dual hinge physics joint (same as wheel joint)
  23213. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23214. */
  23215. export class Hinge2Joint extends MotorEnabledJoint {
  23216. /**
  23217. * Initializes the Hinge2-Joint
  23218. * @param jointData The joint data for the Hinge2-Joint
  23219. */
  23220. constructor(jointData: PhysicsJointData);
  23221. /**
  23222. * Set the motor values.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param {number} targetSpeed the speed the motor is to reach
  23225. * @param {number} maxForce max force for this motor.
  23226. * @param {motorIndex} the motor's index, 0 or 1.
  23227. */
  23228. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23229. /**
  23230. * Set the motor limits.
  23231. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23232. * @param {number} upperLimit the upper limit
  23233. * @param {number} lowerLimit lower limit
  23234. * @param {motorIndex} the motor's index, 0 or 1.
  23235. */
  23236. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23237. }
  23238. /**
  23239. * Interface for a motor enabled joint
  23240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23241. */
  23242. export interface IMotorEnabledJoint {
  23243. /**
  23244. * Physics joint
  23245. */
  23246. physicsJoint: any;
  23247. /**
  23248. * Sets the motor of the motor-enabled joint
  23249. * @param force The force of the motor
  23250. * @param maxForce The maximum force of the motor
  23251. * @param motorIndex The index of the motor
  23252. */
  23253. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23254. /**
  23255. * Sets the limit of the motor
  23256. * @param upperLimit The upper limit of the motor
  23257. * @param lowerLimit The lower limit of the motor
  23258. * @param motorIndex The index of the motor
  23259. */
  23260. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23261. }
  23262. /**
  23263. * Joint data for a Distance-Joint
  23264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23265. */
  23266. export interface DistanceJointData extends PhysicsJointData {
  23267. /**
  23268. * Max distance the 2 joint objects can be apart
  23269. */
  23270. maxDistance: number;
  23271. }
  23272. /**
  23273. * Joint data from a spring joint
  23274. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23275. */
  23276. export interface SpringJointData extends PhysicsJointData {
  23277. /**
  23278. * Length of the spring
  23279. */
  23280. length: number;
  23281. /**
  23282. * Stiffness of the spring
  23283. */
  23284. stiffness: number;
  23285. /**
  23286. * Damping of the spring
  23287. */
  23288. damping: number;
  23289. /** this callback will be called when applying the force to the impostors. */
  23290. forceApplicationCallback: () => void;
  23291. }
  23292. }
  23293. declare module BABYLON {
  23294. /**
  23295. * Holds the data for the raycast result
  23296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23297. */
  23298. export class PhysicsRaycastResult {
  23299. private _hasHit;
  23300. private _hitDistance;
  23301. private _hitNormalWorld;
  23302. private _hitPointWorld;
  23303. private _rayFromWorld;
  23304. private _rayToWorld;
  23305. /**
  23306. * Gets if there was a hit
  23307. */
  23308. get hasHit(): boolean;
  23309. /**
  23310. * Gets the distance from the hit
  23311. */
  23312. get hitDistance(): number;
  23313. /**
  23314. * Gets the hit normal/direction in the world
  23315. */
  23316. get hitNormalWorld(): Vector3;
  23317. /**
  23318. * Gets the hit point in the world
  23319. */
  23320. get hitPointWorld(): Vector3;
  23321. /**
  23322. * Gets the ray "start point" of the ray in the world
  23323. */
  23324. get rayFromWorld(): Vector3;
  23325. /**
  23326. * Gets the ray "end point" of the ray in the world
  23327. */
  23328. get rayToWorld(): Vector3;
  23329. /**
  23330. * Sets the hit data (normal & point in world space)
  23331. * @param hitNormalWorld defines the normal in world space
  23332. * @param hitPointWorld defines the point in world space
  23333. */
  23334. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23335. /**
  23336. * Sets the distance from the start point to the hit point
  23337. * @param distance
  23338. */
  23339. setHitDistance(distance: number): void;
  23340. /**
  23341. * Calculates the distance manually
  23342. */
  23343. calculateHitDistance(): void;
  23344. /**
  23345. * Resets all the values to default
  23346. * @param from The from point on world space
  23347. * @param to The to point on world space
  23348. */
  23349. reset(from?: Vector3, to?: Vector3): void;
  23350. }
  23351. /**
  23352. * Interface for the size containing width and height
  23353. */
  23354. interface IXYZ {
  23355. /**
  23356. * X
  23357. */
  23358. x: number;
  23359. /**
  23360. * Y
  23361. */
  23362. y: number;
  23363. /**
  23364. * Z
  23365. */
  23366. z: number;
  23367. }
  23368. }
  23369. declare module BABYLON {
  23370. /**
  23371. * Interface used to describe a physics joint
  23372. */
  23373. export interface PhysicsImpostorJoint {
  23374. /** Defines the main impostor to which the joint is linked */
  23375. mainImpostor: PhysicsImpostor;
  23376. /** Defines the impostor that is connected to the main impostor using this joint */
  23377. connectedImpostor: PhysicsImpostor;
  23378. /** Defines the joint itself */
  23379. joint: PhysicsJoint;
  23380. }
  23381. /** @hidden */
  23382. export interface IPhysicsEnginePlugin {
  23383. world: any;
  23384. name: string;
  23385. setGravity(gravity: Vector3): void;
  23386. setTimeStep(timeStep: number): void;
  23387. getTimeStep(): number;
  23388. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23389. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23390. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23391. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23392. removePhysicsBody(impostor: PhysicsImpostor): void;
  23393. generateJoint(joint: PhysicsImpostorJoint): void;
  23394. removeJoint(joint: PhysicsImpostorJoint): void;
  23395. isSupported(): boolean;
  23396. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23397. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23398. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23399. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23400. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23401. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23402. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23403. getBodyMass(impostor: PhysicsImpostor): number;
  23404. getBodyFriction(impostor: PhysicsImpostor): number;
  23405. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23406. getBodyRestitution(impostor: PhysicsImpostor): number;
  23407. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23408. getBodyPressure?(impostor: PhysicsImpostor): number;
  23409. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23410. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23411. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23412. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23413. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23414. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23415. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23416. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23417. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23418. sleepBody(impostor: PhysicsImpostor): void;
  23419. wakeUpBody(impostor: PhysicsImpostor): void;
  23420. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23421. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23422. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23423. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23424. getRadius(impostor: PhysicsImpostor): number;
  23425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23426. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23427. dispose(): void;
  23428. }
  23429. /**
  23430. * Interface used to define a physics engine
  23431. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23432. */
  23433. export interface IPhysicsEngine {
  23434. /**
  23435. * Gets the gravity vector used by the simulation
  23436. */
  23437. gravity: Vector3;
  23438. /**
  23439. * Sets the gravity vector used by the simulation
  23440. * @param gravity defines the gravity vector to use
  23441. */
  23442. setGravity(gravity: Vector3): void;
  23443. /**
  23444. * Set the time step of the physics engine.
  23445. * Default is 1/60.
  23446. * To slow it down, enter 1/600 for example.
  23447. * To speed it up, 1/30
  23448. * @param newTimeStep the new timestep to apply to this world.
  23449. */
  23450. setTimeStep(newTimeStep: number): void;
  23451. /**
  23452. * Get the time step of the physics engine.
  23453. * @returns the current time step
  23454. */
  23455. getTimeStep(): number;
  23456. /**
  23457. * Set the sub time step of the physics engine.
  23458. * Default is 0 meaning there is no sub steps
  23459. * To increase physics resolution precision, set a small value (like 1 ms)
  23460. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23461. */
  23462. setSubTimeStep(subTimeStep: number): void;
  23463. /**
  23464. * Get the sub time step of the physics engine.
  23465. * @returns the current sub time step
  23466. */
  23467. getSubTimeStep(): number;
  23468. /**
  23469. * Release all resources
  23470. */
  23471. dispose(): void;
  23472. /**
  23473. * Gets the name of the current physics plugin
  23474. * @returns the name of the plugin
  23475. */
  23476. getPhysicsPluginName(): string;
  23477. /**
  23478. * Adding a new impostor for the impostor tracking.
  23479. * This will be done by the impostor itself.
  23480. * @param impostor the impostor to add
  23481. */
  23482. addImpostor(impostor: PhysicsImpostor): void;
  23483. /**
  23484. * Remove an impostor from the engine.
  23485. * This impostor and its mesh will not longer be updated by the physics engine.
  23486. * @param impostor the impostor to remove
  23487. */
  23488. removeImpostor(impostor: PhysicsImpostor): void;
  23489. /**
  23490. * Add a joint to the physics engine
  23491. * @param mainImpostor defines the main impostor to which the joint is added.
  23492. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23493. * @param joint defines the joint that will connect both impostors.
  23494. */
  23495. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23496. /**
  23497. * Removes a joint from the simulation
  23498. * @param mainImpostor defines the impostor used with the joint
  23499. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23500. * @param joint defines the joint to remove
  23501. */
  23502. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23503. /**
  23504. * Gets the current plugin used to run the simulation
  23505. * @returns current plugin
  23506. */
  23507. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23508. /**
  23509. * Gets the list of physic impostors
  23510. * @returns an array of PhysicsImpostor
  23511. */
  23512. getImpostors(): Array<PhysicsImpostor>;
  23513. /**
  23514. * Gets the impostor for a physics enabled object
  23515. * @param object defines the object impersonated by the impostor
  23516. * @returns the PhysicsImpostor or null if not found
  23517. */
  23518. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23519. /**
  23520. * Gets the impostor for a physics body object
  23521. * @param body defines physics body used by the impostor
  23522. * @returns the PhysicsImpostor or null if not found
  23523. */
  23524. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23525. /**
  23526. * Does a raycast in the physics world
  23527. * @param from when should the ray start?
  23528. * @param to when should the ray end?
  23529. * @returns PhysicsRaycastResult
  23530. */
  23531. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23532. /**
  23533. * Called by the scene. No need to call it.
  23534. * @param delta defines the timespam between frames
  23535. */
  23536. _step(delta: number): void;
  23537. }
  23538. }
  23539. declare module BABYLON {
  23540. /**
  23541. * The interface for the physics imposter parameters
  23542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23543. */
  23544. export interface PhysicsImpostorParameters {
  23545. /**
  23546. * The mass of the physics imposter
  23547. */
  23548. mass: number;
  23549. /**
  23550. * The friction of the physics imposter
  23551. */
  23552. friction?: number;
  23553. /**
  23554. * The coefficient of restitution of the physics imposter
  23555. */
  23556. restitution?: number;
  23557. /**
  23558. * The native options of the physics imposter
  23559. */
  23560. nativeOptions?: any;
  23561. /**
  23562. * Specifies if the parent should be ignored
  23563. */
  23564. ignoreParent?: boolean;
  23565. /**
  23566. * Specifies if bi-directional transformations should be disabled
  23567. */
  23568. disableBidirectionalTransformation?: boolean;
  23569. /**
  23570. * The pressure inside the physics imposter, soft object only
  23571. */
  23572. pressure?: number;
  23573. /**
  23574. * The stiffness the physics imposter, soft object only
  23575. */
  23576. stiffness?: number;
  23577. /**
  23578. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23579. */
  23580. velocityIterations?: number;
  23581. /**
  23582. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23583. */
  23584. positionIterations?: number;
  23585. /**
  23586. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23587. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23588. * Add to fix multiple points
  23589. */
  23590. fixedPoints?: number;
  23591. /**
  23592. * The collision margin around a soft object
  23593. */
  23594. margin?: number;
  23595. /**
  23596. * The collision margin around a soft object
  23597. */
  23598. damping?: number;
  23599. /**
  23600. * The path for a rope based on an extrusion
  23601. */
  23602. path?: any;
  23603. /**
  23604. * The shape of an extrusion used for a rope based on an extrusion
  23605. */
  23606. shape?: any;
  23607. }
  23608. /**
  23609. * Interface for a physics-enabled object
  23610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23611. */
  23612. export interface IPhysicsEnabledObject {
  23613. /**
  23614. * The position of the physics-enabled object
  23615. */
  23616. position: Vector3;
  23617. /**
  23618. * The rotation of the physics-enabled object
  23619. */
  23620. rotationQuaternion: Nullable<Quaternion>;
  23621. /**
  23622. * The scale of the physics-enabled object
  23623. */
  23624. scaling: Vector3;
  23625. /**
  23626. * The rotation of the physics-enabled object
  23627. */
  23628. rotation?: Vector3;
  23629. /**
  23630. * The parent of the physics-enabled object
  23631. */
  23632. parent?: any;
  23633. /**
  23634. * The bounding info of the physics-enabled object
  23635. * @returns The bounding info of the physics-enabled object
  23636. */
  23637. getBoundingInfo(): BoundingInfo;
  23638. /**
  23639. * Computes the world matrix
  23640. * @param force Specifies if the world matrix should be computed by force
  23641. * @returns A world matrix
  23642. */
  23643. computeWorldMatrix(force: boolean): Matrix;
  23644. /**
  23645. * Gets the world matrix
  23646. * @returns A world matrix
  23647. */
  23648. getWorldMatrix?(): Matrix;
  23649. /**
  23650. * Gets the child meshes
  23651. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23652. * @returns An array of abstract meshes
  23653. */
  23654. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23655. /**
  23656. * Gets the vertex data
  23657. * @param kind The type of vertex data
  23658. * @returns A nullable array of numbers, or a float32 array
  23659. */
  23660. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23661. /**
  23662. * Gets the indices from the mesh
  23663. * @returns A nullable array of index arrays
  23664. */
  23665. getIndices?(): Nullable<IndicesArray>;
  23666. /**
  23667. * Gets the scene from the mesh
  23668. * @returns the indices array or null
  23669. */
  23670. getScene?(): Scene;
  23671. /**
  23672. * Gets the absolute position from the mesh
  23673. * @returns the absolute position
  23674. */
  23675. getAbsolutePosition(): Vector3;
  23676. /**
  23677. * Gets the absolute pivot point from the mesh
  23678. * @returns the absolute pivot point
  23679. */
  23680. getAbsolutePivotPoint(): Vector3;
  23681. /**
  23682. * Rotates the mesh
  23683. * @param axis The axis of rotation
  23684. * @param amount The amount of rotation
  23685. * @param space The space of the rotation
  23686. * @returns The rotation transform node
  23687. */
  23688. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23689. /**
  23690. * Translates the mesh
  23691. * @param axis The axis of translation
  23692. * @param distance The distance of translation
  23693. * @param space The space of the translation
  23694. * @returns The transform node
  23695. */
  23696. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23697. /**
  23698. * Sets the absolute position of the mesh
  23699. * @param absolutePosition The absolute position of the mesh
  23700. * @returns The transform node
  23701. */
  23702. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23703. /**
  23704. * Gets the class name of the mesh
  23705. * @returns The class name
  23706. */
  23707. getClassName(): string;
  23708. }
  23709. /**
  23710. * Represents a physics imposter
  23711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23712. */
  23713. export class PhysicsImpostor {
  23714. /**
  23715. * The physics-enabled object used as the physics imposter
  23716. */
  23717. object: IPhysicsEnabledObject;
  23718. /**
  23719. * The type of the physics imposter
  23720. */
  23721. type: number;
  23722. private _options;
  23723. private _scene?;
  23724. /**
  23725. * The default object size of the imposter
  23726. */
  23727. static DEFAULT_OBJECT_SIZE: Vector3;
  23728. /**
  23729. * The identity quaternion of the imposter
  23730. */
  23731. static IDENTITY_QUATERNION: Quaternion;
  23732. /** @hidden */
  23733. _pluginData: any;
  23734. private _physicsEngine;
  23735. private _physicsBody;
  23736. private _bodyUpdateRequired;
  23737. private _onBeforePhysicsStepCallbacks;
  23738. private _onAfterPhysicsStepCallbacks;
  23739. /** @hidden */
  23740. _onPhysicsCollideCallbacks: Array<{
  23741. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23742. otherImpostors: Array<PhysicsImpostor>;
  23743. }>;
  23744. private _deltaPosition;
  23745. private _deltaRotation;
  23746. private _deltaRotationConjugated;
  23747. /** @hidden */
  23748. _isFromLine: boolean;
  23749. private _parent;
  23750. private _isDisposed;
  23751. private static _tmpVecs;
  23752. private static _tmpQuat;
  23753. /**
  23754. * Specifies if the physics imposter is disposed
  23755. */
  23756. get isDisposed(): boolean;
  23757. /**
  23758. * Gets the mass of the physics imposter
  23759. */
  23760. get mass(): number;
  23761. set mass(value: number);
  23762. /**
  23763. * Gets the coefficient of friction
  23764. */
  23765. get friction(): number;
  23766. /**
  23767. * Sets the coefficient of friction
  23768. */
  23769. set friction(value: number);
  23770. /**
  23771. * Gets the coefficient of restitution
  23772. */
  23773. get restitution(): number;
  23774. /**
  23775. * Sets the coefficient of restitution
  23776. */
  23777. set restitution(value: number);
  23778. /**
  23779. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23780. */
  23781. get pressure(): number;
  23782. /**
  23783. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. set pressure(value: number);
  23786. /**
  23787. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23788. */
  23789. get stiffness(): number;
  23790. /**
  23791. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23792. */
  23793. set stiffness(value: number);
  23794. /**
  23795. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23796. */
  23797. get velocityIterations(): number;
  23798. /**
  23799. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23800. */
  23801. set velocityIterations(value: number);
  23802. /**
  23803. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23804. */
  23805. get positionIterations(): number;
  23806. /**
  23807. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23808. */
  23809. set positionIterations(value: number);
  23810. /**
  23811. * The unique id of the physics imposter
  23812. * set by the physics engine when adding this impostor to the array
  23813. */
  23814. uniqueId: number;
  23815. /**
  23816. * @hidden
  23817. */
  23818. soft: boolean;
  23819. /**
  23820. * @hidden
  23821. */
  23822. segments: number;
  23823. private _joints;
  23824. /**
  23825. * Initializes the physics imposter
  23826. * @param object The physics-enabled object used as the physics imposter
  23827. * @param type The type of the physics imposter
  23828. * @param _options The options for the physics imposter
  23829. * @param _scene The Babylon scene
  23830. */
  23831. constructor(
  23832. /**
  23833. * The physics-enabled object used as the physics imposter
  23834. */
  23835. object: IPhysicsEnabledObject,
  23836. /**
  23837. * The type of the physics imposter
  23838. */
  23839. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23840. /**
  23841. * This function will completly initialize this impostor.
  23842. * It will create a new body - but only if this mesh has no parent.
  23843. * If it has, this impostor will not be used other than to define the impostor
  23844. * of the child mesh.
  23845. * @hidden
  23846. */
  23847. _init(): void;
  23848. private _getPhysicsParent;
  23849. /**
  23850. * Should a new body be generated.
  23851. * @returns boolean specifying if body initialization is required
  23852. */
  23853. isBodyInitRequired(): boolean;
  23854. /**
  23855. * Sets the updated scaling
  23856. * @param updated Specifies if the scaling is updated
  23857. */
  23858. setScalingUpdated(): void;
  23859. /**
  23860. * Force a regeneration of this or the parent's impostor's body.
  23861. * Use under cautious - This will remove all joints already implemented.
  23862. */
  23863. forceUpdate(): void;
  23864. /**
  23865. * Gets the body that holds this impostor. Either its own, or its parent.
  23866. */
  23867. get physicsBody(): any;
  23868. /**
  23869. * Get the parent of the physics imposter
  23870. * @returns Physics imposter or null
  23871. */
  23872. get parent(): Nullable<PhysicsImpostor>;
  23873. /**
  23874. * Sets the parent of the physics imposter
  23875. */
  23876. set parent(value: Nullable<PhysicsImpostor>);
  23877. /**
  23878. * Set the physics body. Used mainly by the physics engine/plugin
  23879. */
  23880. set physicsBody(physicsBody: any);
  23881. /**
  23882. * Resets the update flags
  23883. */
  23884. resetUpdateFlags(): void;
  23885. /**
  23886. * Gets the object extend size
  23887. * @returns the object extend size
  23888. */
  23889. getObjectExtendSize(): Vector3;
  23890. /**
  23891. * Gets the object center
  23892. * @returns The object center
  23893. */
  23894. getObjectCenter(): Vector3;
  23895. /**
  23896. * Get a specific parameter from the options parameters
  23897. * @param paramName The object parameter name
  23898. * @returns The object parameter
  23899. */
  23900. getParam(paramName: string): any;
  23901. /**
  23902. * Sets a specific parameter in the options given to the physics plugin
  23903. * @param paramName The parameter name
  23904. * @param value The value of the parameter
  23905. */
  23906. setParam(paramName: string, value: number): void;
  23907. /**
  23908. * Specifically change the body's mass option. Won't recreate the physics body object
  23909. * @param mass The mass of the physics imposter
  23910. */
  23911. setMass(mass: number): void;
  23912. /**
  23913. * Gets the linear velocity
  23914. * @returns linear velocity or null
  23915. */
  23916. getLinearVelocity(): Nullable<Vector3>;
  23917. /**
  23918. * Sets the linear velocity
  23919. * @param velocity linear velocity or null
  23920. */
  23921. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23922. /**
  23923. * Gets the angular velocity
  23924. * @returns angular velocity or null
  23925. */
  23926. getAngularVelocity(): Nullable<Vector3>;
  23927. /**
  23928. * Sets the angular velocity
  23929. * @param velocity The velocity or null
  23930. */
  23931. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23932. /**
  23933. * Execute a function with the physics plugin native code
  23934. * Provide a function the will have two variables - the world object and the physics body object
  23935. * @param func The function to execute with the physics plugin native code
  23936. */
  23937. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23938. /**
  23939. * Register a function that will be executed before the physics world is stepping forward
  23940. * @param func The function to execute before the physics world is stepped forward
  23941. */
  23942. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23943. /**
  23944. * Unregister a function that will be executed before the physics world is stepping forward
  23945. * @param func The function to execute before the physics world is stepped forward
  23946. */
  23947. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23948. /**
  23949. * Register a function that will be executed after the physics step
  23950. * @param func The function to execute after physics step
  23951. */
  23952. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23953. /**
  23954. * Unregisters a function that will be executed after the physics step
  23955. * @param func The function to execute after physics step
  23956. */
  23957. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23958. /**
  23959. * register a function that will be executed when this impostor collides against a different body
  23960. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23961. * @param func Callback that is executed on collision
  23962. */
  23963. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23964. /**
  23965. * Unregisters the physics imposter on contact
  23966. * @param collideAgainst The physics object to collide against
  23967. * @param func Callback to execute on collision
  23968. */
  23969. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23970. private _tmpQuat;
  23971. private _tmpQuat2;
  23972. /**
  23973. * Get the parent rotation
  23974. * @returns The parent rotation
  23975. */
  23976. getParentsRotation(): Quaternion;
  23977. /**
  23978. * this function is executed by the physics engine.
  23979. */
  23980. beforeStep: () => void;
  23981. /**
  23982. * this function is executed by the physics engine
  23983. */
  23984. afterStep: () => void;
  23985. /**
  23986. * Legacy collision detection event support
  23987. */
  23988. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23989. /**
  23990. * event and body object due to cannon's event-based architecture.
  23991. */
  23992. onCollide: (e: {
  23993. body: any;
  23994. }) => void;
  23995. /**
  23996. * Apply a force
  23997. * @param force The force to apply
  23998. * @param contactPoint The contact point for the force
  23999. * @returns The physics imposter
  24000. */
  24001. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24002. /**
  24003. * Apply an impulse
  24004. * @param force The impulse force
  24005. * @param contactPoint The contact point for the impulse force
  24006. * @returns The physics imposter
  24007. */
  24008. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24009. /**
  24010. * A help function to create a joint
  24011. * @param otherImpostor A physics imposter used to create a joint
  24012. * @param jointType The type of joint
  24013. * @param jointData The data for the joint
  24014. * @returns The physics imposter
  24015. */
  24016. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24017. /**
  24018. * Add a joint to this impostor with a different impostor
  24019. * @param otherImpostor A physics imposter used to add a joint
  24020. * @param joint The joint to add
  24021. * @returns The physics imposter
  24022. */
  24023. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24024. /**
  24025. * Add an anchor to a cloth impostor
  24026. * @param otherImpostor rigid impostor to anchor to
  24027. * @param width ratio across width from 0 to 1
  24028. * @param height ratio up height from 0 to 1
  24029. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24030. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24031. * @returns impostor the soft imposter
  24032. */
  24033. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24034. /**
  24035. * Add a hook to a rope impostor
  24036. * @param otherImpostor rigid impostor to anchor to
  24037. * @param length ratio across rope from 0 to 1
  24038. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24039. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24040. * @returns impostor the rope imposter
  24041. */
  24042. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24043. /**
  24044. * Will keep this body still, in a sleep mode.
  24045. * @returns the physics imposter
  24046. */
  24047. sleep(): PhysicsImpostor;
  24048. /**
  24049. * Wake the body up.
  24050. * @returns The physics imposter
  24051. */
  24052. wakeUp(): PhysicsImpostor;
  24053. /**
  24054. * Clones the physics imposter
  24055. * @param newObject The physics imposter clones to this physics-enabled object
  24056. * @returns A nullable physics imposter
  24057. */
  24058. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24059. /**
  24060. * Disposes the physics imposter
  24061. */
  24062. dispose(): void;
  24063. /**
  24064. * Sets the delta position
  24065. * @param position The delta position amount
  24066. */
  24067. setDeltaPosition(position: Vector3): void;
  24068. /**
  24069. * Sets the delta rotation
  24070. * @param rotation The delta rotation amount
  24071. */
  24072. setDeltaRotation(rotation: Quaternion): void;
  24073. /**
  24074. * Gets the box size of the physics imposter and stores the result in the input parameter
  24075. * @param result Stores the box size
  24076. * @returns The physics imposter
  24077. */
  24078. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24079. /**
  24080. * Gets the radius of the physics imposter
  24081. * @returns Radius of the physics imposter
  24082. */
  24083. getRadius(): number;
  24084. /**
  24085. * Sync a bone with this impostor
  24086. * @param bone The bone to sync to the impostor.
  24087. * @param boneMesh The mesh that the bone is influencing.
  24088. * @param jointPivot The pivot of the joint / bone in local space.
  24089. * @param distToJoint Optional distance from the impostor to the joint.
  24090. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24091. */
  24092. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24093. /**
  24094. * Sync impostor to a bone
  24095. * @param bone The bone that the impostor will be synced to.
  24096. * @param boneMesh The mesh that the bone is influencing.
  24097. * @param jointPivot The pivot of the joint / bone in local space.
  24098. * @param distToJoint Optional distance from the impostor to the joint.
  24099. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24100. * @param boneAxis Optional vector3 axis the bone is aligned with
  24101. */
  24102. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24103. /**
  24104. * No-Imposter type
  24105. */
  24106. static NoImpostor: number;
  24107. /**
  24108. * Sphere-Imposter type
  24109. */
  24110. static SphereImpostor: number;
  24111. /**
  24112. * Box-Imposter type
  24113. */
  24114. static BoxImpostor: number;
  24115. /**
  24116. * Plane-Imposter type
  24117. */
  24118. static PlaneImpostor: number;
  24119. /**
  24120. * Mesh-imposter type
  24121. */
  24122. static MeshImpostor: number;
  24123. /**
  24124. * Capsule-Impostor type (Ammo.js plugin only)
  24125. */
  24126. static CapsuleImpostor: number;
  24127. /**
  24128. * Cylinder-Imposter type
  24129. */
  24130. static CylinderImpostor: number;
  24131. /**
  24132. * Particle-Imposter type
  24133. */
  24134. static ParticleImpostor: number;
  24135. /**
  24136. * Heightmap-Imposter type
  24137. */
  24138. static HeightmapImpostor: number;
  24139. /**
  24140. * ConvexHull-Impostor type (Ammo.js plugin only)
  24141. */
  24142. static ConvexHullImpostor: number;
  24143. /**
  24144. * Custom-Imposter type (Ammo.js plugin only)
  24145. */
  24146. static CustomImpostor: number;
  24147. /**
  24148. * Rope-Imposter type
  24149. */
  24150. static RopeImpostor: number;
  24151. /**
  24152. * Cloth-Imposter type
  24153. */
  24154. static ClothImpostor: number;
  24155. /**
  24156. * Softbody-Imposter type
  24157. */
  24158. static SoftbodyImpostor: number;
  24159. }
  24160. }
  24161. declare module BABYLON {
  24162. /**
  24163. * @hidden
  24164. **/
  24165. export class _CreationDataStorage {
  24166. closePath?: boolean;
  24167. closeArray?: boolean;
  24168. idx: number[];
  24169. dashSize: number;
  24170. gapSize: number;
  24171. path3D: Path3D;
  24172. pathArray: Vector3[][];
  24173. arc: number;
  24174. radius: number;
  24175. cap: number;
  24176. tessellation: number;
  24177. }
  24178. /**
  24179. * @hidden
  24180. **/
  24181. class _InstanceDataStorage {
  24182. visibleInstances: any;
  24183. batchCache: _InstancesBatch;
  24184. instancesBufferSize: number;
  24185. instancesBuffer: Nullable<Buffer>;
  24186. instancesData: Float32Array;
  24187. overridenInstanceCount: number;
  24188. isFrozen: boolean;
  24189. previousBatch: Nullable<_InstancesBatch>;
  24190. hardwareInstancedRendering: boolean;
  24191. sideOrientation: number;
  24192. manualUpdate: boolean;
  24193. }
  24194. /**
  24195. * @hidden
  24196. **/
  24197. export class _InstancesBatch {
  24198. mustReturn: boolean;
  24199. visibleInstances: Nullable<InstancedMesh[]>[];
  24200. renderSelf: boolean[];
  24201. hardwareInstancedRendering: boolean[];
  24202. }
  24203. /**
  24204. * Class used to represent renderable models
  24205. */
  24206. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24207. /**
  24208. * Mesh side orientation : usually the external or front surface
  24209. */
  24210. static readonly FRONTSIDE: number;
  24211. /**
  24212. * Mesh side orientation : usually the internal or back surface
  24213. */
  24214. static readonly BACKSIDE: number;
  24215. /**
  24216. * Mesh side orientation : both internal and external or front and back surfaces
  24217. */
  24218. static readonly DOUBLESIDE: number;
  24219. /**
  24220. * Mesh side orientation : by default, `FRONTSIDE`
  24221. */
  24222. static readonly DEFAULTSIDE: number;
  24223. /**
  24224. * Mesh cap setting : no cap
  24225. */
  24226. static readonly NO_CAP: number;
  24227. /**
  24228. * Mesh cap setting : one cap at the beginning of the mesh
  24229. */
  24230. static readonly CAP_START: number;
  24231. /**
  24232. * Mesh cap setting : one cap at the end of the mesh
  24233. */
  24234. static readonly CAP_END: number;
  24235. /**
  24236. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24237. */
  24238. static readonly CAP_ALL: number;
  24239. /**
  24240. * Mesh pattern setting : no flip or rotate
  24241. */
  24242. static readonly NO_FLIP: number;
  24243. /**
  24244. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24245. */
  24246. static readonly FLIP_TILE: number;
  24247. /**
  24248. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24249. */
  24250. static readonly ROTATE_TILE: number;
  24251. /**
  24252. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24253. */
  24254. static readonly FLIP_ROW: number;
  24255. /**
  24256. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24257. */
  24258. static readonly ROTATE_ROW: number;
  24259. /**
  24260. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24261. */
  24262. static readonly FLIP_N_ROTATE_TILE: number;
  24263. /**
  24264. * Mesh pattern setting : rotate pattern and rotate
  24265. */
  24266. static readonly FLIP_N_ROTATE_ROW: number;
  24267. /**
  24268. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24269. */
  24270. static readonly CENTER: number;
  24271. /**
  24272. * Mesh tile positioning : part tiles on left
  24273. */
  24274. static readonly LEFT: number;
  24275. /**
  24276. * Mesh tile positioning : part tiles on right
  24277. */
  24278. static readonly RIGHT: number;
  24279. /**
  24280. * Mesh tile positioning : part tiles on top
  24281. */
  24282. static readonly TOP: number;
  24283. /**
  24284. * Mesh tile positioning : part tiles on bottom
  24285. */
  24286. static readonly BOTTOM: number;
  24287. /**
  24288. * Gets the default side orientation.
  24289. * @param orientation the orientation to value to attempt to get
  24290. * @returns the default orientation
  24291. * @hidden
  24292. */
  24293. static _GetDefaultSideOrientation(orientation?: number): number;
  24294. private _internalMeshDataInfo;
  24295. /**
  24296. * An event triggered before rendering the mesh
  24297. */
  24298. get onBeforeRenderObservable(): Observable<Mesh>;
  24299. /**
  24300. * An event triggered before binding the mesh
  24301. */
  24302. get onBeforeBindObservable(): Observable<Mesh>;
  24303. /**
  24304. * An event triggered after rendering the mesh
  24305. */
  24306. get onAfterRenderObservable(): Observable<Mesh>;
  24307. /**
  24308. * An event triggered before drawing the mesh
  24309. */
  24310. get onBeforeDrawObservable(): Observable<Mesh>;
  24311. private _onBeforeDrawObserver;
  24312. /**
  24313. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24314. */
  24315. set onBeforeDraw(callback: () => void);
  24316. get hasInstances(): boolean;
  24317. /**
  24318. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24319. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24320. */
  24321. delayLoadState: number;
  24322. /**
  24323. * Gets the list of instances created from this mesh
  24324. * it is not supposed to be modified manually.
  24325. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24326. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24327. */
  24328. instances: InstancedMesh[];
  24329. /**
  24330. * Gets the file containing delay loading data for this mesh
  24331. */
  24332. delayLoadingFile: string;
  24333. /** @hidden */
  24334. _binaryInfo: any;
  24335. /**
  24336. * User defined function used to change how LOD level selection is done
  24337. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24338. */
  24339. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24340. /**
  24341. * Gets or sets the morph target manager
  24342. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24343. */
  24344. get morphTargetManager(): Nullable<MorphTargetManager>;
  24345. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24346. /** @hidden */
  24347. _creationDataStorage: Nullable<_CreationDataStorage>;
  24348. /** @hidden */
  24349. _geometry: Nullable<Geometry>;
  24350. /** @hidden */
  24351. _delayInfo: Array<string>;
  24352. /** @hidden */
  24353. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24354. /** @hidden */
  24355. _instanceDataStorage: _InstanceDataStorage;
  24356. private _effectiveMaterial;
  24357. /** @hidden */
  24358. _shouldGenerateFlatShading: boolean;
  24359. /** @hidden */
  24360. _originalBuilderSideOrientation: number;
  24361. /**
  24362. * Use this property to change the original side orientation defined at construction time
  24363. */
  24364. overrideMaterialSideOrientation: Nullable<number>;
  24365. /**
  24366. * Gets the source mesh (the one used to clone this one from)
  24367. */
  24368. get source(): Nullable<Mesh>;
  24369. /**
  24370. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24371. */
  24372. get isUnIndexed(): boolean;
  24373. set isUnIndexed(value: boolean);
  24374. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24375. get worldMatrixInstancedBuffer(): Float32Array;
  24376. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24377. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24378. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24379. /**
  24380. * @constructor
  24381. * @param name The value used by scene.getMeshByName() to do a lookup.
  24382. * @param scene The scene to add this mesh to.
  24383. * @param parent The parent of this mesh, if it has one
  24384. * @param source An optional Mesh from which geometry is shared, cloned.
  24385. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24386. * When false, achieved by calling a clone(), also passing False.
  24387. * This will make creation of children, recursive.
  24388. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24389. */
  24390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24391. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24392. doNotInstantiate: boolean;
  24393. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24394. /**
  24395. * Gets the class name
  24396. * @returns the string "Mesh".
  24397. */
  24398. getClassName(): string;
  24399. /** @hidden */
  24400. get _isMesh(): boolean;
  24401. /**
  24402. * Returns a description of this mesh
  24403. * @param fullDetails define if full details about this mesh must be used
  24404. * @returns a descriptive string representing this mesh
  24405. */
  24406. toString(fullDetails?: boolean): string;
  24407. /** @hidden */
  24408. _unBindEffect(): void;
  24409. /**
  24410. * Gets a boolean indicating if this mesh has LOD
  24411. */
  24412. get hasLODLevels(): boolean;
  24413. /**
  24414. * Gets the list of MeshLODLevel associated with the current mesh
  24415. * @returns an array of MeshLODLevel
  24416. */
  24417. getLODLevels(): MeshLODLevel[];
  24418. private _sortLODLevels;
  24419. /**
  24420. * Add a mesh as LOD level triggered at the given distance.
  24421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24422. * @param distance The distance from the center of the object to show this level
  24423. * @param mesh The mesh to be added as LOD level (can be null)
  24424. * @return This mesh (for chaining)
  24425. */
  24426. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24427. /**
  24428. * Returns the LOD level mesh at the passed distance or null if not found.
  24429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24430. * @param distance The distance from the center of the object to show this level
  24431. * @returns a Mesh or `null`
  24432. */
  24433. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24434. /**
  24435. * Remove a mesh from the LOD array
  24436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24437. * @param mesh defines the mesh to be removed
  24438. * @return This mesh (for chaining)
  24439. */
  24440. removeLODLevel(mesh: Mesh): Mesh;
  24441. /**
  24442. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24443. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24444. * @param camera defines the camera to use to compute distance
  24445. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24446. * @return This mesh (for chaining)
  24447. */
  24448. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24449. /**
  24450. * Gets the mesh internal Geometry object
  24451. */
  24452. get geometry(): Nullable<Geometry>;
  24453. /**
  24454. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24455. * @returns the total number of vertices
  24456. */
  24457. getTotalVertices(): number;
  24458. /**
  24459. * Returns the content of an associated vertex buffer
  24460. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24461. * - VertexBuffer.PositionKind
  24462. * - VertexBuffer.UVKind
  24463. * - VertexBuffer.UV2Kind
  24464. * - VertexBuffer.UV3Kind
  24465. * - VertexBuffer.UV4Kind
  24466. * - VertexBuffer.UV5Kind
  24467. * - VertexBuffer.UV6Kind
  24468. * - VertexBuffer.ColorKind
  24469. * - VertexBuffer.MatricesIndicesKind
  24470. * - VertexBuffer.MatricesIndicesExtraKind
  24471. * - VertexBuffer.MatricesWeightsKind
  24472. * - VertexBuffer.MatricesWeightsExtraKind
  24473. * @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
  24474. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24475. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24476. */
  24477. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24478. /**
  24479. * Returns the mesh VertexBuffer object from the requested `kind`
  24480. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24481. * - VertexBuffer.PositionKind
  24482. * - VertexBuffer.NormalKind
  24483. * - VertexBuffer.UVKind
  24484. * - VertexBuffer.UV2Kind
  24485. * - VertexBuffer.UV3Kind
  24486. * - VertexBuffer.UV4Kind
  24487. * - VertexBuffer.UV5Kind
  24488. * - VertexBuffer.UV6Kind
  24489. * - VertexBuffer.ColorKind
  24490. * - VertexBuffer.MatricesIndicesKind
  24491. * - VertexBuffer.MatricesIndicesExtraKind
  24492. * - VertexBuffer.MatricesWeightsKind
  24493. * - VertexBuffer.MatricesWeightsExtraKind
  24494. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24495. */
  24496. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24497. /**
  24498. * Tests if a specific vertex buffer is associated with this mesh
  24499. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24500. * - VertexBuffer.PositionKind
  24501. * - VertexBuffer.NormalKind
  24502. * - VertexBuffer.UVKind
  24503. * - VertexBuffer.UV2Kind
  24504. * - VertexBuffer.UV3Kind
  24505. * - VertexBuffer.UV4Kind
  24506. * - VertexBuffer.UV5Kind
  24507. * - VertexBuffer.UV6Kind
  24508. * - VertexBuffer.ColorKind
  24509. * - VertexBuffer.MatricesIndicesKind
  24510. * - VertexBuffer.MatricesIndicesExtraKind
  24511. * - VertexBuffer.MatricesWeightsKind
  24512. * - VertexBuffer.MatricesWeightsExtraKind
  24513. * @returns a boolean
  24514. */
  24515. isVerticesDataPresent(kind: string): boolean;
  24516. /**
  24517. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24518. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24519. * - VertexBuffer.PositionKind
  24520. * - VertexBuffer.UVKind
  24521. * - VertexBuffer.UV2Kind
  24522. * - VertexBuffer.UV3Kind
  24523. * - VertexBuffer.UV4Kind
  24524. * - VertexBuffer.UV5Kind
  24525. * - VertexBuffer.UV6Kind
  24526. * - VertexBuffer.ColorKind
  24527. * - VertexBuffer.MatricesIndicesKind
  24528. * - VertexBuffer.MatricesIndicesExtraKind
  24529. * - VertexBuffer.MatricesWeightsKind
  24530. * - VertexBuffer.MatricesWeightsExtraKind
  24531. * @returns a boolean
  24532. */
  24533. isVertexBufferUpdatable(kind: string): boolean;
  24534. /**
  24535. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24536. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24537. * - VertexBuffer.PositionKind
  24538. * - VertexBuffer.NormalKind
  24539. * - VertexBuffer.UVKind
  24540. * - VertexBuffer.UV2Kind
  24541. * - VertexBuffer.UV3Kind
  24542. * - VertexBuffer.UV4Kind
  24543. * - VertexBuffer.UV5Kind
  24544. * - VertexBuffer.UV6Kind
  24545. * - VertexBuffer.ColorKind
  24546. * - VertexBuffer.MatricesIndicesKind
  24547. * - VertexBuffer.MatricesIndicesExtraKind
  24548. * - VertexBuffer.MatricesWeightsKind
  24549. * - VertexBuffer.MatricesWeightsExtraKind
  24550. * @returns an array of strings
  24551. */
  24552. getVerticesDataKinds(): string[];
  24553. /**
  24554. * Returns a positive integer : the total number of indices in this mesh geometry.
  24555. * @returns the numner of indices or zero if the mesh has no geometry.
  24556. */
  24557. getTotalIndices(): number;
  24558. /**
  24559. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24560. * @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.
  24561. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24562. * @returns the indices array or an empty array if the mesh has no geometry
  24563. */
  24564. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24565. get isBlocked(): boolean;
  24566. /**
  24567. * Determine if the current mesh is ready to be rendered
  24568. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24569. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24570. * @returns true if all associated assets are ready (material, textures, shaders)
  24571. */
  24572. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24573. /**
  24574. * 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.
  24575. */
  24576. get areNormalsFrozen(): boolean;
  24577. /**
  24578. * 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.
  24579. * @returns the current mesh
  24580. */
  24581. freezeNormals(): Mesh;
  24582. /**
  24583. * 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
  24584. * @returns the current mesh
  24585. */
  24586. unfreezeNormals(): Mesh;
  24587. /**
  24588. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24589. */
  24590. set overridenInstanceCount(count: number);
  24591. /** @hidden */
  24592. _preActivate(): Mesh;
  24593. /** @hidden */
  24594. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24595. /** @hidden */
  24596. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24597. /**
  24598. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24599. * This means the mesh underlying bounding box and sphere are recomputed.
  24600. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24601. * @returns the current mesh
  24602. */
  24603. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24604. /** @hidden */
  24605. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24606. /**
  24607. * This function will subdivide the mesh into multiple submeshes
  24608. * @param count defines the expected number of submeshes
  24609. */
  24610. subdivide(count: number): void;
  24611. /**
  24612. * Copy a FloatArray into a specific associated vertex buffer
  24613. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24614. * - VertexBuffer.PositionKind
  24615. * - VertexBuffer.UVKind
  24616. * - VertexBuffer.UV2Kind
  24617. * - VertexBuffer.UV3Kind
  24618. * - VertexBuffer.UV4Kind
  24619. * - VertexBuffer.UV5Kind
  24620. * - VertexBuffer.UV6Kind
  24621. * - VertexBuffer.ColorKind
  24622. * - VertexBuffer.MatricesIndicesKind
  24623. * - VertexBuffer.MatricesIndicesExtraKind
  24624. * - VertexBuffer.MatricesWeightsKind
  24625. * - VertexBuffer.MatricesWeightsExtraKind
  24626. * @param data defines the data source
  24627. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24628. * @param stride defines the data stride size (can be null)
  24629. * @returns the current mesh
  24630. */
  24631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24632. /**
  24633. * Delete a vertex buffer associated with this mesh
  24634. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24635. * - VertexBuffer.PositionKind
  24636. * - VertexBuffer.UVKind
  24637. * - VertexBuffer.UV2Kind
  24638. * - VertexBuffer.UV3Kind
  24639. * - VertexBuffer.UV4Kind
  24640. * - VertexBuffer.UV5Kind
  24641. * - VertexBuffer.UV6Kind
  24642. * - VertexBuffer.ColorKind
  24643. * - VertexBuffer.MatricesIndicesKind
  24644. * - VertexBuffer.MatricesIndicesExtraKind
  24645. * - VertexBuffer.MatricesWeightsKind
  24646. * - VertexBuffer.MatricesWeightsExtraKind
  24647. */
  24648. removeVerticesData(kind: string): void;
  24649. /**
  24650. * Flags an associated vertex buffer as updatable
  24651. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24652. * - VertexBuffer.PositionKind
  24653. * - VertexBuffer.UVKind
  24654. * - VertexBuffer.UV2Kind
  24655. * - VertexBuffer.UV3Kind
  24656. * - VertexBuffer.UV4Kind
  24657. * - VertexBuffer.UV5Kind
  24658. * - VertexBuffer.UV6Kind
  24659. * - VertexBuffer.ColorKind
  24660. * - VertexBuffer.MatricesIndicesKind
  24661. * - VertexBuffer.MatricesIndicesExtraKind
  24662. * - VertexBuffer.MatricesWeightsKind
  24663. * - VertexBuffer.MatricesWeightsExtraKind
  24664. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24665. */
  24666. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24667. /**
  24668. * Sets the mesh global Vertex Buffer
  24669. * @param buffer defines the buffer to use
  24670. * @returns the current mesh
  24671. */
  24672. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24673. /**
  24674. * Update a specific associated vertex buffer
  24675. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24676. * - VertexBuffer.PositionKind
  24677. * - VertexBuffer.UVKind
  24678. * - VertexBuffer.UV2Kind
  24679. * - VertexBuffer.UV3Kind
  24680. * - VertexBuffer.UV4Kind
  24681. * - VertexBuffer.UV5Kind
  24682. * - VertexBuffer.UV6Kind
  24683. * - VertexBuffer.ColorKind
  24684. * - VertexBuffer.MatricesIndicesKind
  24685. * - VertexBuffer.MatricesIndicesExtraKind
  24686. * - VertexBuffer.MatricesWeightsKind
  24687. * - VertexBuffer.MatricesWeightsExtraKind
  24688. * @param data defines the data source
  24689. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24690. * @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)
  24691. * @returns the current mesh
  24692. */
  24693. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24694. /**
  24695. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24696. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24697. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24698. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24699. * @returns the current mesh
  24700. */
  24701. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24702. /**
  24703. * Creates a un-shared specific occurence of the geometry for the mesh.
  24704. * @returns the current mesh
  24705. */
  24706. makeGeometryUnique(): Mesh;
  24707. /**
  24708. * Set the index buffer of this mesh
  24709. * @param indices defines the source data
  24710. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24711. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24712. * @returns the current mesh
  24713. */
  24714. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24715. /**
  24716. * Update the current index buffer
  24717. * @param indices defines the source data
  24718. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24719. * @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)
  24720. * @returns the current mesh
  24721. */
  24722. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24723. /**
  24724. * Invert the geometry to move from a right handed system to a left handed one.
  24725. * @returns the current mesh
  24726. */
  24727. toLeftHanded(): Mesh;
  24728. /** @hidden */
  24729. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24730. /** @hidden */
  24731. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24732. /**
  24733. * Registers for this mesh a javascript function called just before the rendering process
  24734. * @param func defines the function to call before rendering this mesh
  24735. * @returns the current mesh
  24736. */
  24737. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24738. /**
  24739. * Disposes a previously registered javascript function called before the rendering
  24740. * @param func defines the function to remove
  24741. * @returns the current mesh
  24742. */
  24743. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24744. /**
  24745. * Registers for this mesh a javascript function called just after the rendering is complete
  24746. * @param func defines the function to call after rendering this mesh
  24747. * @returns the current mesh
  24748. */
  24749. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24750. /**
  24751. * Disposes a previously registered javascript function called after the rendering.
  24752. * @param func defines the function to remove
  24753. * @returns the current mesh
  24754. */
  24755. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24756. /** @hidden */
  24757. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24758. /** @hidden */
  24759. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24760. /** @hidden */
  24761. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24762. /** @hidden */
  24763. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24764. /** @hidden */
  24765. _rebuild(): void;
  24766. /** @hidden */
  24767. _freeze(): void;
  24768. /** @hidden */
  24769. _unFreeze(): void;
  24770. /**
  24771. * 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
  24772. * @param subMesh defines the subMesh to render
  24773. * @param enableAlphaMode defines if alpha mode can be changed
  24774. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24775. * @returns the current mesh
  24776. */
  24777. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24778. private _onBeforeDraw;
  24779. /**
  24780. * Renormalize the mesh and patch it up if there are no weights
  24781. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24782. * However in the case of zero weights then we set just a single influence to 1.
  24783. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24784. */
  24785. cleanMatrixWeights(): void;
  24786. private normalizeSkinFourWeights;
  24787. private normalizeSkinWeightsAndExtra;
  24788. /**
  24789. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24790. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24791. * the user know there was an issue with importing the mesh
  24792. * @returns a validation object with skinned, valid and report string
  24793. */
  24794. validateSkinning(): {
  24795. skinned: boolean;
  24796. valid: boolean;
  24797. report: string;
  24798. };
  24799. /** @hidden */
  24800. _checkDelayState(): Mesh;
  24801. private _queueLoad;
  24802. /**
  24803. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24804. * A mesh is in the frustum if its bounding box intersects the frustum
  24805. * @param frustumPlanes defines the frustum to test
  24806. * @returns true if the mesh is in the frustum planes
  24807. */
  24808. isInFrustum(frustumPlanes: Plane[]): boolean;
  24809. /**
  24810. * Sets the mesh material by the material or multiMaterial `id` property
  24811. * @param id is a string identifying the material or the multiMaterial
  24812. * @returns the current mesh
  24813. */
  24814. setMaterialByID(id: string): Mesh;
  24815. /**
  24816. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24817. * @returns an array of IAnimatable
  24818. */
  24819. getAnimatables(): IAnimatable[];
  24820. /**
  24821. * Modifies the mesh geometry according to the passed transformation matrix.
  24822. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24823. * The mesh normals are modified using the same transformation.
  24824. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24825. * @param transform defines the transform matrix to use
  24826. * @see http://doc.babylonjs.com/resources/baking_transformations
  24827. * @returns the current mesh
  24828. */
  24829. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24830. /**
  24831. * Modifies the mesh geometry according to its own current World Matrix.
  24832. * The mesh World Matrix is then reset.
  24833. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24834. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24835. * @see http://doc.babylonjs.com/resources/baking_transformations
  24836. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24837. * @returns the current mesh
  24838. */
  24839. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24840. /** @hidden */
  24841. get _positions(): Nullable<Vector3[]>;
  24842. /** @hidden */
  24843. _resetPointsArrayCache(): Mesh;
  24844. /** @hidden */
  24845. _generatePointsArray(): boolean;
  24846. /**
  24847. * Returns a new Mesh object generated from the current mesh properties.
  24848. * This method must not get confused with createInstance()
  24849. * @param name is a string, the name given to the new mesh
  24850. * @param newParent can be any Node object (default `null`)
  24851. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24852. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24853. * @returns a new mesh
  24854. */
  24855. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24856. /**
  24857. * Releases resources associated with this mesh.
  24858. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24859. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24860. */
  24861. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24862. /** @hidden */
  24863. _disposeInstanceSpecificData(): void;
  24864. /**
  24865. * Modifies the mesh geometry according to a displacement map.
  24866. * 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.
  24867. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24868. * @param url is a string, the URL from the image file is to be downloaded.
  24869. * @param minHeight is the lower limit of the displacement.
  24870. * @param maxHeight is the upper limit of the displacement.
  24871. * @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.
  24872. * @param uvOffset is an optional vector2 used to offset UV.
  24873. * @param uvScale is an optional vector2 used to scale UV.
  24874. * @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.
  24875. * @returns the Mesh.
  24876. */
  24877. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24878. /**
  24879. * Modifies the mesh geometry according to a displacementMap buffer.
  24880. * 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.
  24881. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24882. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24883. * @param heightMapWidth is the width of the buffer image.
  24884. * @param heightMapHeight is the height of the buffer image.
  24885. * @param minHeight is the lower limit of the displacement.
  24886. * @param maxHeight is the upper limit of the displacement.
  24887. * @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.
  24888. * @param uvOffset is an optional vector2 used to offset UV.
  24889. * @param uvScale is an optional vector2 used to scale UV.
  24890. * @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.
  24891. * @returns the Mesh.
  24892. */
  24893. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24894. /**
  24895. * Modify the mesh to get a flat shading rendering.
  24896. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24897. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24898. * @returns current mesh
  24899. */
  24900. convertToFlatShadedMesh(): Mesh;
  24901. /**
  24902. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24903. * In other words, more vertices, no more indices and a single bigger VBO.
  24904. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24905. * @returns current mesh
  24906. */
  24907. convertToUnIndexedMesh(): Mesh;
  24908. /**
  24909. * Inverses facet orientations.
  24910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24911. * @param flipNormals will also inverts the normals
  24912. * @returns current mesh
  24913. */
  24914. flipFaces(flipNormals?: boolean): Mesh;
  24915. /**
  24916. * Increase the number of facets and hence vertices in a mesh
  24917. * Vertex normals are interpolated from existing vertex normals
  24918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24919. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24920. */
  24921. increaseVertices(numberPerEdge: number): void;
  24922. /**
  24923. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24924. * This will undo any application of covertToFlatShadedMesh
  24925. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24926. */
  24927. forceSharedVertices(): void;
  24928. /** @hidden */
  24929. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24930. /** @hidden */
  24931. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24932. /**
  24933. * Creates a new InstancedMesh object from the mesh model.
  24934. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24935. * @param name defines the name of the new instance
  24936. * @returns a new InstancedMesh
  24937. */
  24938. createInstance(name: string): InstancedMesh;
  24939. /**
  24940. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24941. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24942. * @returns the current mesh
  24943. */
  24944. synchronizeInstances(): Mesh;
  24945. /**
  24946. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24947. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24948. * This should be used together with the simplification to avoid disappearing triangles.
  24949. * @param successCallback an optional success callback to be called after the optimization finished.
  24950. * @returns the current mesh
  24951. */
  24952. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24953. /**
  24954. * Serialize current mesh
  24955. * @param serializationObject defines the object which will receive the serialization data
  24956. */
  24957. serialize(serializationObject: any): void;
  24958. /** @hidden */
  24959. _syncGeometryWithMorphTargetManager(): void;
  24960. /** @hidden */
  24961. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24962. /**
  24963. * Returns a new Mesh object parsed from the source provided.
  24964. * @param parsedMesh is the source
  24965. * @param scene defines the hosting scene
  24966. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24967. * @returns a new Mesh
  24968. */
  24969. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24970. /**
  24971. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24972. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24973. * @param name defines the name of the mesh to create
  24974. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24975. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24976. * @param closePath creates a seam between the first and the last points of each path of the path array
  24977. * @param offset is taken in account only if the `pathArray` is containing a single path
  24978. * @param scene defines the hosting scene
  24979. * @param updatable defines if the mesh must be flagged as updatable
  24980. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24981. * @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)
  24982. * @returns a new Mesh
  24983. */
  24984. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24985. /**
  24986. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24987. * @param name defines the name of the mesh to create
  24988. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24989. * @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
  24990. * @param scene defines the hosting scene
  24991. * @param updatable defines if the mesh must be flagged as updatable
  24992. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24993. * @returns a new Mesh
  24994. */
  24995. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24996. /**
  24997. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24998. * @param name defines the name of the mesh to create
  24999. * @param size sets the size (float) of each box side (default 1)
  25000. * @param scene defines the hosting scene
  25001. * @param updatable defines if the mesh must be flagged as updatable
  25002. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25003. * @returns a new Mesh
  25004. */
  25005. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25006. /**
  25007. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25008. * @param name defines the name of the mesh to create
  25009. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25010. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25011. * @param scene defines the hosting scene
  25012. * @param updatable defines if the mesh must be flagged as updatable
  25013. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25014. * @returns a new Mesh
  25015. */
  25016. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25017. /**
  25018. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25019. * @param name defines the name of the mesh to create
  25020. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25021. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25022. * @param scene defines the hosting scene
  25023. * @returns a new Mesh
  25024. */
  25025. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25026. /**
  25027. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25028. * @param name defines the name of the mesh to create
  25029. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25030. * @param diameterTop set the top cap diameter (floats, default 1)
  25031. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25032. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25033. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25034. * @param scene defines the hosting scene
  25035. * @param updatable defines if the mesh must be flagged as updatable
  25036. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25037. * @returns a new Mesh
  25038. */
  25039. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25040. /**
  25041. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25042. * @param name defines the name of the mesh to create
  25043. * @param diameter sets the diameter size (float) of the torus (default 1)
  25044. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25045. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25046. * @param scene defines the hosting scene
  25047. * @param updatable defines if the mesh must be flagged as updatable
  25048. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25049. * @returns a new Mesh
  25050. */
  25051. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25052. /**
  25053. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25054. * @param name defines the name of the mesh to create
  25055. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25056. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25057. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25058. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25059. * @param p the number of windings on X axis (positive integers, default 2)
  25060. * @param q the number of windings on Y axis (positive integers, default 3)
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @returns a new Mesh
  25065. */
  25066. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25067. /**
  25068. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25069. * @param name defines the name of the mesh to create
  25070. * @param points is an array successive Vector3
  25071. * @param scene defines the hosting scene
  25072. * @param updatable defines if the mesh must be flagged as updatable
  25073. * @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).
  25074. * @returns a new Mesh
  25075. */
  25076. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25077. /**
  25078. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25079. * @param name defines the name of the mesh to create
  25080. * @param points is an array successive Vector3
  25081. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25082. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25083. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25084. * @param scene defines the hosting scene
  25085. * @param updatable defines if the mesh must be flagged as updatable
  25086. * @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)
  25087. * @returns a new Mesh
  25088. */
  25089. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25090. /**
  25091. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25093. * 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.
  25094. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25095. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25096. * Remember you can only change the shape positions, not their number when updating a polygon.
  25097. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25098. * @param name defines the name of the mesh to create
  25099. * @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
  25100. * @param scene defines the hosting scene
  25101. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25102. * @param updatable defines if the mesh must be flagged as updatable
  25103. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25104. * @param earcutInjection can be used to inject your own earcut reference
  25105. * @returns a new Mesh
  25106. */
  25107. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25108. /**
  25109. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25110. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25111. * @param name defines the name of the mesh to create
  25112. * @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
  25113. * @param depth defines the height of extrusion
  25114. * @param scene defines the hosting scene
  25115. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25116. * @param updatable defines if the mesh must be flagged as updatable
  25117. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25118. * @param earcutInjection can be used to inject your own earcut reference
  25119. * @returns a new Mesh
  25120. */
  25121. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25122. /**
  25123. * Creates an extruded shape mesh.
  25124. * 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
  25125. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25126. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25127. * @param name defines the name of the mesh to create
  25128. * @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
  25129. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25130. * @param scale is the value to scale the shape
  25131. * @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
  25132. * @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
  25133. * @param scene defines the hosting scene
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25136. * @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)
  25137. * @returns a new Mesh
  25138. */
  25139. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25140. /**
  25141. * Creates an custom extruded shape mesh.
  25142. * The custom extrusion is a parametric shape.
  25143. * It has no predefined shape. Its final shape will depend on the input parameters.
  25144. * Please consider using the same method from the MeshBuilder class instead
  25145. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25146. * @param name defines the name of the mesh to create
  25147. * @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
  25148. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25149. * @param scaleFunction is a custom Javascript function called on each path point
  25150. * @param rotationFunction is a custom Javascript function called on each path point
  25151. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25152. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25153. * @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
  25154. * @param scene defines the hosting scene
  25155. * @param updatable defines if the mesh must be flagged as updatable
  25156. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25157. * @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)
  25158. * @returns a new Mesh
  25159. */
  25160. 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;
  25161. /**
  25162. * Creates lathe mesh.
  25163. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25164. * Please consider using the same method from the MeshBuilder class instead
  25165. * @param name defines the name of the mesh to create
  25166. * @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
  25167. * @param radius is the radius value of the lathe
  25168. * @param tessellation is the side number of the lathe.
  25169. * @param scene defines the hosting scene
  25170. * @param updatable defines if the mesh must be flagged as updatable
  25171. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25172. * @returns a new Mesh
  25173. */
  25174. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25175. /**
  25176. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25177. * @param name defines the name of the mesh to create
  25178. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25179. * @param scene defines the hosting scene
  25180. * @param updatable defines if the mesh must be flagged as updatable
  25181. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25182. * @returns a new Mesh
  25183. */
  25184. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25185. /**
  25186. * Creates a ground mesh.
  25187. * Please consider using the same method from the MeshBuilder class instead
  25188. * @param name defines the name of the mesh to create
  25189. * @param width set the width of the ground
  25190. * @param height set the height of the ground
  25191. * @param subdivisions sets the number of subdivisions per side
  25192. * @param scene defines the hosting scene
  25193. * @param updatable defines if the mesh must be flagged as updatable
  25194. * @returns a new Mesh
  25195. */
  25196. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25197. /**
  25198. * Creates a tiled ground mesh.
  25199. * Please consider using the same method from the MeshBuilder class instead
  25200. * @param name defines the name of the mesh to create
  25201. * @param xmin set the ground minimum X coordinate
  25202. * @param zmin set the ground minimum Y coordinate
  25203. * @param xmax set the ground maximum X coordinate
  25204. * @param zmax set the ground maximum Z coordinate
  25205. * @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
  25206. * @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
  25207. * @param scene defines the hosting scene
  25208. * @param updatable defines if the mesh must be flagged as updatable
  25209. * @returns a new Mesh
  25210. */
  25211. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25212. w: number;
  25213. h: number;
  25214. }, precision: {
  25215. w: number;
  25216. h: number;
  25217. }, scene: Scene, updatable?: boolean): Mesh;
  25218. /**
  25219. * Creates a ground mesh from a height map.
  25220. * Please consider using the same method from the MeshBuilder class instead
  25221. * @see http://doc.babylonjs.com/babylon101/height_map
  25222. * @param name defines the name of the mesh to create
  25223. * @param url sets the URL of the height map image resource
  25224. * @param width set the ground width size
  25225. * @param height set the ground height size
  25226. * @param subdivisions sets the number of subdivision per side
  25227. * @param minHeight is the minimum altitude on the ground
  25228. * @param maxHeight is the maximum altitude on the ground
  25229. * @param scene defines the hosting scene
  25230. * @param updatable defines if the mesh must be flagged as updatable
  25231. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25232. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25233. * @returns a new Mesh
  25234. */
  25235. 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;
  25236. /**
  25237. * Creates a tube mesh.
  25238. * The tube is a parametric shape.
  25239. * It has no predefined shape. Its final shape will depend on the input parameters.
  25240. * Please consider using the same method from the MeshBuilder class instead
  25241. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25242. * @param name defines the name of the mesh to create
  25243. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25244. * @param radius sets the tube radius size
  25245. * @param tessellation is the number of sides on the tubular surface
  25246. * @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
  25247. * @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
  25248. * @param scene defines the hosting scene
  25249. * @param updatable defines if the mesh must be flagged as updatable
  25250. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25251. * @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)
  25252. * @returns a new Mesh
  25253. */
  25254. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25255. (i: number, distance: number): number;
  25256. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25257. /**
  25258. * Creates a polyhedron mesh.
  25259. * Please consider using the same method from the MeshBuilder class instead.
  25260. * * 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
  25261. * * The parameter `size` (positive float, default 1) sets the polygon size
  25262. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25263. * * 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`
  25264. * * 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
  25265. * * 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)`)
  25266. * * 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
  25267. * * 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
  25268. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25269. * * 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
  25270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25271. * @param name defines the name of the mesh to create
  25272. * @param options defines the options used to create the mesh
  25273. * @param scene defines the hosting scene
  25274. * @returns a new Mesh
  25275. */
  25276. static CreatePolyhedron(name: string, options: {
  25277. type?: number;
  25278. size?: number;
  25279. sizeX?: number;
  25280. sizeY?: number;
  25281. sizeZ?: number;
  25282. custom?: any;
  25283. faceUV?: Vector4[];
  25284. faceColors?: Color4[];
  25285. updatable?: boolean;
  25286. sideOrientation?: number;
  25287. }, scene: Scene): Mesh;
  25288. /**
  25289. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25290. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25291. * * 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`)
  25292. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25293. * * 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
  25294. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25295. * * 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
  25296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25297. * @param name defines the name of the mesh
  25298. * @param options defines the options used to create the mesh
  25299. * @param scene defines the hosting scene
  25300. * @returns a new Mesh
  25301. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25302. */
  25303. static CreateIcoSphere(name: string, options: {
  25304. radius?: number;
  25305. flat?: boolean;
  25306. subdivisions?: number;
  25307. sideOrientation?: number;
  25308. updatable?: boolean;
  25309. }, scene: Scene): Mesh;
  25310. /**
  25311. * Creates a decal mesh.
  25312. * Please consider using the same method from the MeshBuilder class instead.
  25313. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25314. * @param name defines the name of the mesh
  25315. * @param sourceMesh defines the mesh receiving the decal
  25316. * @param position sets the position of the decal in world coordinates
  25317. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25318. * @param size sets the decal scaling
  25319. * @param angle sets the angle to rotate the decal
  25320. * @returns a new Mesh
  25321. */
  25322. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25323. /**
  25324. * Prepare internal position array for software CPU skinning
  25325. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25326. */
  25327. setPositionsForCPUSkinning(): Float32Array;
  25328. /**
  25329. * Prepare internal normal array for software CPU skinning
  25330. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25331. */
  25332. setNormalsForCPUSkinning(): Float32Array;
  25333. /**
  25334. * Updates the vertex buffer by applying transformation from the bones
  25335. * @param skeleton defines the skeleton to apply to current mesh
  25336. * @returns the current mesh
  25337. */
  25338. applySkeleton(skeleton: Skeleton): Mesh;
  25339. /**
  25340. * 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
  25341. * @param meshes defines the list of meshes to scan
  25342. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25343. */
  25344. static MinMax(meshes: AbstractMesh[]): {
  25345. min: Vector3;
  25346. max: Vector3;
  25347. };
  25348. /**
  25349. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25350. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25351. * @returns a vector3
  25352. */
  25353. static Center(meshesOrMinMaxVector: {
  25354. min: Vector3;
  25355. max: Vector3;
  25356. } | AbstractMesh[]): Vector3;
  25357. /**
  25358. * Merge the array of meshes into a single mesh for performance reasons.
  25359. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25360. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25361. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25362. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25363. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25364. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25365. * @returns a new mesh
  25366. */
  25367. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25368. /** @hidden */
  25369. addInstance(instance: InstancedMesh): void;
  25370. /** @hidden */
  25371. removeInstance(instance: InstancedMesh): void;
  25372. }
  25373. }
  25374. declare module BABYLON {
  25375. /**
  25376. * This is the base class of all the camera used in the application.
  25377. * @see http://doc.babylonjs.com/features/cameras
  25378. */
  25379. export class Camera extends Node {
  25380. /** @hidden */
  25381. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25382. /**
  25383. * This is the default projection mode used by the cameras.
  25384. * It helps recreating a feeling of perspective and better appreciate depth.
  25385. * This is the best way to simulate real life cameras.
  25386. */
  25387. static readonly PERSPECTIVE_CAMERA: number;
  25388. /**
  25389. * This helps creating camera with an orthographic mode.
  25390. * 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.
  25391. */
  25392. static readonly ORTHOGRAPHIC_CAMERA: number;
  25393. /**
  25394. * This is the default FOV mode for perspective cameras.
  25395. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25396. */
  25397. static readonly FOVMODE_VERTICAL_FIXED: number;
  25398. /**
  25399. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25400. */
  25401. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25402. /**
  25403. * This specifies ther is no need for a camera rig.
  25404. * Basically only one eye is rendered corresponding to the camera.
  25405. */
  25406. static readonly RIG_MODE_NONE: number;
  25407. /**
  25408. * Simulates a camera Rig with one blue eye and one red eye.
  25409. * This can be use with 3d blue and red glasses.
  25410. */
  25411. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25412. /**
  25413. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25414. */
  25415. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25416. /**
  25417. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25418. */
  25419. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25420. /**
  25421. * Defines that both eyes of the camera will be rendered over under each other.
  25422. */
  25423. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25424. /**
  25425. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25426. */
  25427. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25428. /**
  25429. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25430. */
  25431. static readonly RIG_MODE_VR: number;
  25432. /**
  25433. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25434. */
  25435. static readonly RIG_MODE_WEBVR: number;
  25436. /**
  25437. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25438. */
  25439. static readonly RIG_MODE_CUSTOM: number;
  25440. /**
  25441. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25442. */
  25443. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25444. /**
  25445. * Define the input manager associated with the camera.
  25446. */
  25447. inputs: CameraInputsManager<Camera>;
  25448. /** @hidden */
  25449. _position: Vector3;
  25450. /**
  25451. * Define the current local position of the camera in the scene
  25452. */
  25453. get position(): Vector3;
  25454. set position(newPosition: Vector3);
  25455. /**
  25456. * The vector the camera should consider as up.
  25457. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25458. */
  25459. upVector: Vector3;
  25460. /**
  25461. * Define the current limit on the left side for an orthographic camera
  25462. * In scene unit
  25463. */
  25464. orthoLeft: Nullable<number>;
  25465. /**
  25466. * Define the current limit on the right side for an orthographic camera
  25467. * In scene unit
  25468. */
  25469. orthoRight: Nullable<number>;
  25470. /**
  25471. * Define the current limit on the bottom side for an orthographic camera
  25472. * In scene unit
  25473. */
  25474. orthoBottom: Nullable<number>;
  25475. /**
  25476. * Define the current limit on the top side for an orthographic camera
  25477. * In scene unit
  25478. */
  25479. orthoTop: Nullable<number>;
  25480. /**
  25481. * Field Of View is set in Radians. (default is 0.8)
  25482. */
  25483. fov: number;
  25484. /**
  25485. * Define the minimum distance the camera can see from.
  25486. * This is important to note that the depth buffer are not infinite and the closer it starts
  25487. * the more your scene might encounter depth fighting issue.
  25488. */
  25489. minZ: number;
  25490. /**
  25491. * Define the maximum distance the camera can see to.
  25492. * This is important to note that the depth buffer are not infinite and the further it end
  25493. * the more your scene might encounter depth fighting issue.
  25494. */
  25495. maxZ: number;
  25496. /**
  25497. * Define the default inertia of the camera.
  25498. * This helps giving a smooth feeling to the camera movement.
  25499. */
  25500. inertia: number;
  25501. /**
  25502. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25503. */
  25504. mode: number;
  25505. /**
  25506. * Define whether the camera is intermediate.
  25507. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25508. */
  25509. isIntermediate: boolean;
  25510. /**
  25511. * Define the viewport of the camera.
  25512. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25513. */
  25514. viewport: Viewport;
  25515. /**
  25516. * Restricts the camera to viewing objects with the same layerMask.
  25517. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25518. */
  25519. layerMask: number;
  25520. /**
  25521. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25522. */
  25523. fovMode: number;
  25524. /**
  25525. * Rig mode of the camera.
  25526. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25527. * This is normally controlled byt the camera themselves as internal use.
  25528. */
  25529. cameraRigMode: number;
  25530. /**
  25531. * Defines the distance between both "eyes" in case of a RIG
  25532. */
  25533. interaxialDistance: number;
  25534. /**
  25535. * Defines if stereoscopic rendering is done side by side or over under.
  25536. */
  25537. isStereoscopicSideBySide: boolean;
  25538. /**
  25539. * 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
  25540. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25541. * else in the scene. (Eg. security camera)
  25542. *
  25543. * 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)
  25544. */
  25545. customRenderTargets: RenderTargetTexture[];
  25546. /**
  25547. * When set, the camera will render to this render target instead of the default canvas
  25548. *
  25549. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25550. */
  25551. outputRenderTarget: Nullable<RenderTargetTexture>;
  25552. /**
  25553. * Observable triggered when the camera view matrix has changed.
  25554. */
  25555. onViewMatrixChangedObservable: Observable<Camera>;
  25556. /**
  25557. * Observable triggered when the camera Projection matrix has changed.
  25558. */
  25559. onProjectionMatrixChangedObservable: Observable<Camera>;
  25560. /**
  25561. * Observable triggered when the inputs have been processed.
  25562. */
  25563. onAfterCheckInputsObservable: Observable<Camera>;
  25564. /**
  25565. * Observable triggered when reset has been called and applied to the camera.
  25566. */
  25567. onRestoreStateObservable: Observable<Camera>;
  25568. /**
  25569. * Is this camera a part of a rig system?
  25570. */
  25571. isRigCamera: boolean;
  25572. /**
  25573. * If isRigCamera set to true this will be set with the parent camera.
  25574. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25575. */
  25576. rigParent?: Camera;
  25577. /** @hidden */
  25578. _cameraRigParams: any;
  25579. /** @hidden */
  25580. _rigCameras: Camera[];
  25581. /** @hidden */
  25582. _rigPostProcess: Nullable<PostProcess>;
  25583. protected _webvrViewMatrix: Matrix;
  25584. /** @hidden */
  25585. _skipRendering: boolean;
  25586. /** @hidden */
  25587. _projectionMatrix: Matrix;
  25588. /** @hidden */
  25589. _postProcesses: Nullable<PostProcess>[];
  25590. /** @hidden */
  25591. _activeMeshes: SmartArray<AbstractMesh>;
  25592. protected _globalPosition: Vector3;
  25593. /** @hidden */
  25594. _computedViewMatrix: Matrix;
  25595. private _doNotComputeProjectionMatrix;
  25596. private _transformMatrix;
  25597. private _frustumPlanes;
  25598. private _refreshFrustumPlanes;
  25599. private _storedFov;
  25600. private _stateStored;
  25601. /**
  25602. * Instantiates a new camera object.
  25603. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25604. * @see http://doc.babylonjs.com/features/cameras
  25605. * @param name Defines the name of the camera in the scene
  25606. * @param position Defines the position of the camera
  25607. * @param scene Defines the scene the camera belongs too
  25608. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25609. */
  25610. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25611. /**
  25612. * Store current camera state (fov, position, etc..)
  25613. * @returns the camera
  25614. */
  25615. storeState(): Camera;
  25616. /**
  25617. * Restores the camera state values if it has been stored. You must call storeState() first
  25618. */
  25619. protected _restoreStateValues(): boolean;
  25620. /**
  25621. * Restored camera state. You must call storeState() first.
  25622. * @returns true if restored and false otherwise
  25623. */
  25624. restoreState(): boolean;
  25625. /**
  25626. * Gets the class name of the camera.
  25627. * @returns the class name
  25628. */
  25629. getClassName(): string;
  25630. /** @hidden */
  25631. readonly _isCamera: boolean;
  25632. /**
  25633. * Gets a string representation of the camera useful for debug purpose.
  25634. * @param fullDetails Defines that a more verboe level of logging is required
  25635. * @returns the string representation
  25636. */
  25637. toString(fullDetails?: boolean): string;
  25638. /**
  25639. * Gets the current world space position of the camera.
  25640. */
  25641. get globalPosition(): Vector3;
  25642. /**
  25643. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25644. * @returns the active meshe list
  25645. */
  25646. getActiveMeshes(): SmartArray<AbstractMesh>;
  25647. /**
  25648. * Check whether a mesh is part of the current active mesh list of the camera
  25649. * @param mesh Defines the mesh to check
  25650. * @returns true if active, false otherwise
  25651. */
  25652. isActiveMesh(mesh: Mesh): boolean;
  25653. /**
  25654. * Is this camera ready to be used/rendered
  25655. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25656. * @return true if the camera is ready
  25657. */
  25658. isReady(completeCheck?: boolean): boolean;
  25659. /** @hidden */
  25660. _initCache(): void;
  25661. /** @hidden */
  25662. _updateCache(ignoreParentClass?: boolean): void;
  25663. /** @hidden */
  25664. _isSynchronized(): boolean;
  25665. /** @hidden */
  25666. _isSynchronizedViewMatrix(): boolean;
  25667. /** @hidden */
  25668. _isSynchronizedProjectionMatrix(): boolean;
  25669. /**
  25670. * Attach the input controls to a specific dom element to get the input from.
  25671. * @param element Defines the element the controls should be listened from
  25672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25673. */
  25674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25675. /**
  25676. * Detach the current controls from the specified dom element.
  25677. * @param element Defines the element to stop listening the inputs from
  25678. */
  25679. detachControl(element: HTMLElement): void;
  25680. /**
  25681. * Update the camera state according to the different inputs gathered during the frame.
  25682. */
  25683. update(): void;
  25684. /** @hidden */
  25685. _checkInputs(): void;
  25686. /** @hidden */
  25687. get rigCameras(): Camera[];
  25688. /**
  25689. * Gets the post process used by the rig cameras
  25690. */
  25691. get rigPostProcess(): Nullable<PostProcess>;
  25692. /**
  25693. * Internal, gets the first post proces.
  25694. * @returns the first post process to be run on this camera.
  25695. */
  25696. _getFirstPostProcess(): Nullable<PostProcess>;
  25697. private _cascadePostProcessesToRigCams;
  25698. /**
  25699. * Attach a post process to the camera.
  25700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25701. * @param postProcess The post process to attach to the camera
  25702. * @param insertAt The position of the post process in case several of them are in use in the scene
  25703. * @returns the position the post process has been inserted at
  25704. */
  25705. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25706. /**
  25707. * Detach a post process to the camera.
  25708. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25709. * @param postProcess The post process to detach from the camera
  25710. */
  25711. detachPostProcess(postProcess: PostProcess): void;
  25712. /**
  25713. * Gets the current world matrix of the camera
  25714. */
  25715. getWorldMatrix(): Matrix;
  25716. /** @hidden */
  25717. _getViewMatrix(): Matrix;
  25718. /**
  25719. * Gets the current view matrix of the camera.
  25720. * @param force forces the camera to recompute the matrix without looking at the cached state
  25721. * @returns the view matrix
  25722. */
  25723. getViewMatrix(force?: boolean): Matrix;
  25724. /**
  25725. * Freeze the projection matrix.
  25726. * It will prevent the cache check of the camera projection compute and can speed up perf
  25727. * if no parameter of the camera are meant to change
  25728. * @param projection Defines manually a projection if necessary
  25729. */
  25730. freezeProjectionMatrix(projection?: Matrix): void;
  25731. /**
  25732. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25733. */
  25734. unfreezeProjectionMatrix(): void;
  25735. /**
  25736. * Gets the current projection matrix of the camera.
  25737. * @param force forces the camera to recompute the matrix without looking at the cached state
  25738. * @returns the projection matrix
  25739. */
  25740. getProjectionMatrix(force?: boolean): Matrix;
  25741. /**
  25742. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25743. * @returns a Matrix
  25744. */
  25745. getTransformationMatrix(): Matrix;
  25746. private _updateFrustumPlanes;
  25747. /**
  25748. * Checks if a cullable object (mesh...) is in the camera frustum
  25749. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25750. * @param target The object to check
  25751. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25752. * @returns true if the object is in frustum otherwise false
  25753. */
  25754. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25755. /**
  25756. * Checks if a cullable object (mesh...) is in the camera frustum
  25757. * Unlike isInFrustum this cheks the full bounding box
  25758. * @param target The object to check
  25759. * @returns true if the object is in frustum otherwise false
  25760. */
  25761. isCompletelyInFrustum(target: ICullable): boolean;
  25762. /**
  25763. * Gets a ray in the forward direction from the camera.
  25764. * @param length Defines the length of the ray to create
  25765. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25766. * @param origin Defines the start point of the ray which defaults to the camera position
  25767. * @returns the forward ray
  25768. */
  25769. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25770. /**
  25771. * Releases resources associated with this node.
  25772. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25773. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25774. */
  25775. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25776. /** @hidden */
  25777. _isLeftCamera: boolean;
  25778. /**
  25779. * Gets the left camera of a rig setup in case of Rigged Camera
  25780. */
  25781. get isLeftCamera(): boolean;
  25782. /** @hidden */
  25783. _isRightCamera: boolean;
  25784. /**
  25785. * Gets the right camera of a rig setup in case of Rigged Camera
  25786. */
  25787. get isRightCamera(): boolean;
  25788. /**
  25789. * Gets the left camera of a rig setup in case of Rigged Camera
  25790. */
  25791. get leftCamera(): Nullable<FreeCamera>;
  25792. /**
  25793. * Gets the right camera of a rig setup in case of Rigged Camera
  25794. */
  25795. get rightCamera(): Nullable<FreeCamera>;
  25796. /**
  25797. * Gets the left camera target of a rig setup in case of Rigged Camera
  25798. * @returns the target position
  25799. */
  25800. getLeftTarget(): Nullable<Vector3>;
  25801. /**
  25802. * Gets the right camera target of a rig setup in case of Rigged Camera
  25803. * @returns the target position
  25804. */
  25805. getRightTarget(): Nullable<Vector3>;
  25806. /**
  25807. * @hidden
  25808. */
  25809. setCameraRigMode(mode: number, rigParams: any): void;
  25810. /** @hidden */
  25811. static _setStereoscopicRigMode(camera: Camera): void;
  25812. /** @hidden */
  25813. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25814. /** @hidden */
  25815. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25816. /** @hidden */
  25817. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25818. /** @hidden */
  25819. _getVRProjectionMatrix(): Matrix;
  25820. protected _updateCameraRotationMatrix(): void;
  25821. protected _updateWebVRCameraRotationMatrix(): void;
  25822. /**
  25823. * This function MUST be overwritten by the different WebVR cameras available.
  25824. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25825. * @hidden
  25826. */
  25827. _getWebVRProjectionMatrix(): Matrix;
  25828. /**
  25829. * This function MUST be overwritten by the different WebVR cameras available.
  25830. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25831. * @hidden
  25832. */
  25833. _getWebVRViewMatrix(): Matrix;
  25834. /** @hidden */
  25835. setCameraRigParameter(name: string, value: any): void;
  25836. /**
  25837. * needs to be overridden by children so sub has required properties to be copied
  25838. * @hidden
  25839. */
  25840. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25841. /**
  25842. * May need to be overridden by children
  25843. * @hidden
  25844. */
  25845. _updateRigCameras(): void;
  25846. /** @hidden */
  25847. _setupInputs(): void;
  25848. /**
  25849. * Serialiaze the camera setup to a json represention
  25850. * @returns the JSON representation
  25851. */
  25852. serialize(): any;
  25853. /**
  25854. * Clones the current camera.
  25855. * @param name The cloned camera name
  25856. * @returns the cloned camera
  25857. */
  25858. clone(name: string): Camera;
  25859. /**
  25860. * Gets the direction of the camera relative to a given local axis.
  25861. * @param localAxis Defines the reference axis to provide a relative direction.
  25862. * @return the direction
  25863. */
  25864. getDirection(localAxis: Vector3): Vector3;
  25865. /**
  25866. * Returns the current camera absolute rotation
  25867. */
  25868. get absoluteRotation(): Quaternion;
  25869. /**
  25870. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25871. * @param localAxis Defines the reference axis to provide a relative direction.
  25872. * @param result Defines the vector to store the result in
  25873. */
  25874. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25875. /**
  25876. * Gets a camera constructor for a given camera type
  25877. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25878. * @param name The name of the camera the result will be able to instantiate
  25879. * @param scene The scene the result will construct the camera in
  25880. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25881. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25882. * @returns a factory method to construc the camera
  25883. */
  25884. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25885. /**
  25886. * Compute the world matrix of the camera.
  25887. * @returns the camera world matrix
  25888. */
  25889. computeWorldMatrix(): Matrix;
  25890. /**
  25891. * Parse a JSON and creates the camera from the parsed information
  25892. * @param parsedCamera The JSON to parse
  25893. * @param scene The scene to instantiate the camera in
  25894. * @returns the newly constructed camera
  25895. */
  25896. static Parse(parsedCamera: any, scene: Scene): Camera;
  25897. }
  25898. }
  25899. declare module BABYLON {
  25900. /**
  25901. * Class containing static functions to help procedurally build meshes
  25902. */
  25903. export class DiscBuilder {
  25904. /**
  25905. * Creates a plane polygonal mesh. By default, this is a disc
  25906. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25907. * * 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
  25908. * * 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
  25909. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25910. * * 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
  25911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25912. * @param name defines the name of the mesh
  25913. * @param options defines the options used to create the mesh
  25914. * @param scene defines the hosting scene
  25915. * @returns the plane polygonal mesh
  25916. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25917. */
  25918. static CreateDisc(name: string, options: {
  25919. radius?: number;
  25920. tessellation?: number;
  25921. arc?: number;
  25922. updatable?: boolean;
  25923. sideOrientation?: number;
  25924. frontUVs?: Vector4;
  25925. backUVs?: Vector4;
  25926. }, scene?: Nullable<Scene>): Mesh;
  25927. }
  25928. }
  25929. declare module BABYLON {
  25930. /**
  25931. * This represents all the required information to add a fresnel effect on a material:
  25932. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25933. */
  25934. export class FresnelParameters {
  25935. private _isEnabled;
  25936. /**
  25937. * Define if the fresnel effect is enable or not.
  25938. */
  25939. get isEnabled(): boolean;
  25940. set isEnabled(value: boolean);
  25941. /**
  25942. * Define the color used on edges (grazing angle)
  25943. */
  25944. leftColor: Color3;
  25945. /**
  25946. * Define the color used on center
  25947. */
  25948. rightColor: Color3;
  25949. /**
  25950. * Define bias applied to computed fresnel term
  25951. */
  25952. bias: number;
  25953. /**
  25954. * Defined the power exponent applied to fresnel term
  25955. */
  25956. power: number;
  25957. /**
  25958. * Clones the current fresnel and its valuues
  25959. * @returns a clone fresnel configuration
  25960. */
  25961. clone(): FresnelParameters;
  25962. /**
  25963. * Serializes the current fresnel parameters to a JSON representation.
  25964. * @return the JSON serialization
  25965. */
  25966. serialize(): any;
  25967. /**
  25968. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25969. * @param parsedFresnelParameters Define the JSON representation
  25970. * @returns the parsed parameters
  25971. */
  25972. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25973. }
  25974. }
  25975. declare module BABYLON {
  25976. /**
  25977. * Base class of materials working in push mode in babylon JS
  25978. * @hidden
  25979. */
  25980. export class PushMaterial extends Material {
  25981. protected _activeEffect: Effect;
  25982. protected _normalMatrix: Matrix;
  25983. /**
  25984. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25985. * This means that the material can keep using a previous shader while a new one is being compiled.
  25986. * This is mostly used when shader parallel compilation is supported (true by default)
  25987. */
  25988. allowShaderHotSwapping: boolean;
  25989. constructor(name: string, scene: Scene);
  25990. getEffect(): Effect;
  25991. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25992. /**
  25993. * Binds the given world matrix to the active effect
  25994. *
  25995. * @param world the matrix to bind
  25996. */
  25997. bindOnlyWorldMatrix(world: Matrix): void;
  25998. /**
  25999. * Binds the given normal matrix to the active effect
  26000. *
  26001. * @param normalMatrix the matrix to bind
  26002. */
  26003. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26004. bind(world: Matrix, mesh?: Mesh): void;
  26005. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26006. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26007. }
  26008. }
  26009. declare module BABYLON {
  26010. /**
  26011. * This groups all the flags used to control the materials channel.
  26012. */
  26013. export class MaterialFlags {
  26014. private static _DiffuseTextureEnabled;
  26015. /**
  26016. * Are diffuse textures enabled in the application.
  26017. */
  26018. static get DiffuseTextureEnabled(): boolean;
  26019. static set DiffuseTextureEnabled(value: boolean);
  26020. private static _AmbientTextureEnabled;
  26021. /**
  26022. * Are ambient textures enabled in the application.
  26023. */
  26024. static get AmbientTextureEnabled(): boolean;
  26025. static set AmbientTextureEnabled(value: boolean);
  26026. private static _OpacityTextureEnabled;
  26027. /**
  26028. * Are opacity textures enabled in the application.
  26029. */
  26030. static get OpacityTextureEnabled(): boolean;
  26031. static set OpacityTextureEnabled(value: boolean);
  26032. private static _ReflectionTextureEnabled;
  26033. /**
  26034. * Are reflection textures enabled in the application.
  26035. */
  26036. static get ReflectionTextureEnabled(): boolean;
  26037. static set ReflectionTextureEnabled(value: boolean);
  26038. private static _EmissiveTextureEnabled;
  26039. /**
  26040. * Are emissive textures enabled in the application.
  26041. */
  26042. static get EmissiveTextureEnabled(): boolean;
  26043. static set EmissiveTextureEnabled(value: boolean);
  26044. private static _SpecularTextureEnabled;
  26045. /**
  26046. * Are specular textures enabled in the application.
  26047. */
  26048. static get SpecularTextureEnabled(): boolean;
  26049. static set SpecularTextureEnabled(value: boolean);
  26050. private static _BumpTextureEnabled;
  26051. /**
  26052. * Are bump textures enabled in the application.
  26053. */
  26054. static get BumpTextureEnabled(): boolean;
  26055. static set BumpTextureEnabled(value: boolean);
  26056. private static _LightmapTextureEnabled;
  26057. /**
  26058. * Are lightmap textures enabled in the application.
  26059. */
  26060. static get LightmapTextureEnabled(): boolean;
  26061. static set LightmapTextureEnabled(value: boolean);
  26062. private static _RefractionTextureEnabled;
  26063. /**
  26064. * Are refraction textures enabled in the application.
  26065. */
  26066. static get RefractionTextureEnabled(): boolean;
  26067. static set RefractionTextureEnabled(value: boolean);
  26068. private static _ColorGradingTextureEnabled;
  26069. /**
  26070. * Are color grading textures enabled in the application.
  26071. */
  26072. static get ColorGradingTextureEnabled(): boolean;
  26073. static set ColorGradingTextureEnabled(value: boolean);
  26074. private static _FresnelEnabled;
  26075. /**
  26076. * Are fresnels enabled in the application.
  26077. */
  26078. static get FresnelEnabled(): boolean;
  26079. static set FresnelEnabled(value: boolean);
  26080. private static _ClearCoatTextureEnabled;
  26081. /**
  26082. * Are clear coat textures enabled in the application.
  26083. */
  26084. static get ClearCoatTextureEnabled(): boolean;
  26085. static set ClearCoatTextureEnabled(value: boolean);
  26086. private static _ClearCoatBumpTextureEnabled;
  26087. /**
  26088. * Are clear coat bump textures enabled in the application.
  26089. */
  26090. static get ClearCoatBumpTextureEnabled(): boolean;
  26091. static set ClearCoatBumpTextureEnabled(value: boolean);
  26092. private static _ClearCoatTintTextureEnabled;
  26093. /**
  26094. * Are clear coat tint textures enabled in the application.
  26095. */
  26096. static get ClearCoatTintTextureEnabled(): boolean;
  26097. static set ClearCoatTintTextureEnabled(value: boolean);
  26098. private static _SheenTextureEnabled;
  26099. /**
  26100. * Are sheen textures enabled in the application.
  26101. */
  26102. static get SheenTextureEnabled(): boolean;
  26103. static set SheenTextureEnabled(value: boolean);
  26104. private static _AnisotropicTextureEnabled;
  26105. /**
  26106. * Are anisotropic textures enabled in the application.
  26107. */
  26108. static get AnisotropicTextureEnabled(): boolean;
  26109. static set AnisotropicTextureEnabled(value: boolean);
  26110. private static _ThicknessTextureEnabled;
  26111. /**
  26112. * Are thickness textures enabled in the application.
  26113. */
  26114. static get ThicknessTextureEnabled(): boolean;
  26115. static set ThicknessTextureEnabled(value: boolean);
  26116. }
  26117. }
  26118. declare module BABYLON {
  26119. /** @hidden */
  26120. export var defaultFragmentDeclaration: {
  26121. name: string;
  26122. shader: string;
  26123. };
  26124. }
  26125. declare module BABYLON {
  26126. /** @hidden */
  26127. export var defaultUboDeclaration: {
  26128. name: string;
  26129. shader: string;
  26130. };
  26131. }
  26132. declare module BABYLON {
  26133. /** @hidden */
  26134. export var lightFragmentDeclaration: {
  26135. name: string;
  26136. shader: string;
  26137. };
  26138. }
  26139. declare module BABYLON {
  26140. /** @hidden */
  26141. export var lightUboDeclaration: {
  26142. name: string;
  26143. shader: string;
  26144. };
  26145. }
  26146. declare module BABYLON {
  26147. /** @hidden */
  26148. export var lightsFragmentFunctions: {
  26149. name: string;
  26150. shader: string;
  26151. };
  26152. }
  26153. declare module BABYLON {
  26154. /** @hidden */
  26155. export var shadowsFragmentFunctions: {
  26156. name: string;
  26157. shader: string;
  26158. };
  26159. }
  26160. declare module BABYLON {
  26161. /** @hidden */
  26162. export var fresnelFunction: {
  26163. name: string;
  26164. shader: string;
  26165. };
  26166. }
  26167. declare module BABYLON {
  26168. /** @hidden */
  26169. export var reflectionFunction: {
  26170. name: string;
  26171. shader: string;
  26172. };
  26173. }
  26174. declare module BABYLON {
  26175. /** @hidden */
  26176. export var bumpFragmentFunctions: {
  26177. name: string;
  26178. shader: string;
  26179. };
  26180. }
  26181. declare module BABYLON {
  26182. /** @hidden */
  26183. export var logDepthDeclaration: {
  26184. name: string;
  26185. shader: string;
  26186. };
  26187. }
  26188. declare module BABYLON {
  26189. /** @hidden */
  26190. export var bumpFragment: {
  26191. name: string;
  26192. shader: string;
  26193. };
  26194. }
  26195. declare module BABYLON {
  26196. /** @hidden */
  26197. export var depthPrePass: {
  26198. name: string;
  26199. shader: string;
  26200. };
  26201. }
  26202. declare module BABYLON {
  26203. /** @hidden */
  26204. export var lightFragment: {
  26205. name: string;
  26206. shader: string;
  26207. };
  26208. }
  26209. declare module BABYLON {
  26210. /** @hidden */
  26211. export var logDepthFragment: {
  26212. name: string;
  26213. shader: string;
  26214. };
  26215. }
  26216. declare module BABYLON {
  26217. /** @hidden */
  26218. export var defaultPixelShader: {
  26219. name: string;
  26220. shader: string;
  26221. };
  26222. }
  26223. declare module BABYLON {
  26224. /** @hidden */
  26225. export var defaultVertexDeclaration: {
  26226. name: string;
  26227. shader: string;
  26228. };
  26229. }
  26230. declare module BABYLON {
  26231. /** @hidden */
  26232. export var bumpVertexDeclaration: {
  26233. name: string;
  26234. shader: string;
  26235. };
  26236. }
  26237. declare module BABYLON {
  26238. /** @hidden */
  26239. export var bumpVertex: {
  26240. name: string;
  26241. shader: string;
  26242. };
  26243. }
  26244. declare module BABYLON {
  26245. /** @hidden */
  26246. export var fogVertex: {
  26247. name: string;
  26248. shader: string;
  26249. };
  26250. }
  26251. declare module BABYLON {
  26252. /** @hidden */
  26253. export var shadowsVertex: {
  26254. name: string;
  26255. shader: string;
  26256. };
  26257. }
  26258. declare module BABYLON {
  26259. /** @hidden */
  26260. export var pointCloudVertex: {
  26261. name: string;
  26262. shader: string;
  26263. };
  26264. }
  26265. declare module BABYLON {
  26266. /** @hidden */
  26267. export var logDepthVertex: {
  26268. name: string;
  26269. shader: string;
  26270. };
  26271. }
  26272. declare module BABYLON {
  26273. /** @hidden */
  26274. export var defaultVertexShader: {
  26275. name: string;
  26276. shader: string;
  26277. };
  26278. }
  26279. declare module BABYLON {
  26280. /** @hidden */
  26281. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26282. MAINUV1: boolean;
  26283. MAINUV2: boolean;
  26284. DIFFUSE: boolean;
  26285. DIFFUSEDIRECTUV: number;
  26286. AMBIENT: boolean;
  26287. AMBIENTDIRECTUV: number;
  26288. OPACITY: boolean;
  26289. OPACITYDIRECTUV: number;
  26290. OPACITYRGB: boolean;
  26291. REFLECTION: boolean;
  26292. EMISSIVE: boolean;
  26293. EMISSIVEDIRECTUV: number;
  26294. SPECULAR: boolean;
  26295. SPECULARDIRECTUV: number;
  26296. BUMP: boolean;
  26297. BUMPDIRECTUV: number;
  26298. PARALLAX: boolean;
  26299. PARALLAXOCCLUSION: boolean;
  26300. SPECULAROVERALPHA: boolean;
  26301. CLIPPLANE: boolean;
  26302. CLIPPLANE2: boolean;
  26303. CLIPPLANE3: boolean;
  26304. CLIPPLANE4: boolean;
  26305. CLIPPLANE5: boolean;
  26306. CLIPPLANE6: boolean;
  26307. ALPHATEST: boolean;
  26308. DEPTHPREPASS: boolean;
  26309. ALPHAFROMDIFFUSE: boolean;
  26310. POINTSIZE: boolean;
  26311. FOG: boolean;
  26312. SPECULARTERM: boolean;
  26313. DIFFUSEFRESNEL: boolean;
  26314. OPACITYFRESNEL: boolean;
  26315. REFLECTIONFRESNEL: boolean;
  26316. REFRACTIONFRESNEL: boolean;
  26317. EMISSIVEFRESNEL: boolean;
  26318. FRESNEL: boolean;
  26319. NORMAL: boolean;
  26320. UV1: boolean;
  26321. UV2: boolean;
  26322. VERTEXCOLOR: boolean;
  26323. VERTEXALPHA: boolean;
  26324. NUM_BONE_INFLUENCERS: number;
  26325. BonesPerMesh: number;
  26326. BONETEXTURE: boolean;
  26327. INSTANCES: boolean;
  26328. GLOSSINESS: boolean;
  26329. ROUGHNESS: boolean;
  26330. EMISSIVEASILLUMINATION: boolean;
  26331. LINKEMISSIVEWITHDIFFUSE: boolean;
  26332. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26333. LIGHTMAP: boolean;
  26334. LIGHTMAPDIRECTUV: number;
  26335. OBJECTSPACE_NORMALMAP: boolean;
  26336. USELIGHTMAPASSHADOWMAP: boolean;
  26337. REFLECTIONMAP_3D: boolean;
  26338. REFLECTIONMAP_SPHERICAL: boolean;
  26339. REFLECTIONMAP_PLANAR: boolean;
  26340. REFLECTIONMAP_CUBIC: boolean;
  26341. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26342. REFLECTIONMAP_PROJECTION: boolean;
  26343. REFLECTIONMAP_SKYBOX: boolean;
  26344. REFLECTIONMAP_EXPLICIT: boolean;
  26345. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26346. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26347. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26348. INVERTCUBICMAP: boolean;
  26349. LOGARITHMICDEPTH: boolean;
  26350. REFRACTION: boolean;
  26351. REFRACTIONMAP_3D: boolean;
  26352. REFLECTIONOVERALPHA: boolean;
  26353. TWOSIDEDLIGHTING: boolean;
  26354. SHADOWFLOAT: boolean;
  26355. MORPHTARGETS: boolean;
  26356. MORPHTARGETS_NORMAL: boolean;
  26357. MORPHTARGETS_TANGENT: boolean;
  26358. MORPHTARGETS_UV: boolean;
  26359. NUM_MORPH_INFLUENCERS: number;
  26360. NONUNIFORMSCALING: boolean;
  26361. PREMULTIPLYALPHA: boolean;
  26362. IMAGEPROCESSING: boolean;
  26363. VIGNETTE: boolean;
  26364. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26365. VIGNETTEBLENDMODEOPAQUE: boolean;
  26366. TONEMAPPING: boolean;
  26367. TONEMAPPING_ACES: boolean;
  26368. CONTRAST: boolean;
  26369. COLORCURVES: boolean;
  26370. COLORGRADING: boolean;
  26371. COLORGRADING3D: boolean;
  26372. SAMPLER3DGREENDEPTH: boolean;
  26373. SAMPLER3DBGRMAP: boolean;
  26374. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26375. MULTIVIEW: boolean;
  26376. /**
  26377. * If the reflection texture on this material is in linear color space
  26378. * @hidden
  26379. */
  26380. IS_REFLECTION_LINEAR: boolean;
  26381. /**
  26382. * If the refraction texture on this material is in linear color space
  26383. * @hidden
  26384. */
  26385. IS_REFRACTION_LINEAR: boolean;
  26386. EXPOSURE: boolean;
  26387. constructor();
  26388. setReflectionMode(modeToEnable: string): void;
  26389. }
  26390. /**
  26391. * This is the default material used in Babylon. It is the best trade off between quality
  26392. * and performances.
  26393. * @see http://doc.babylonjs.com/babylon101/materials
  26394. */
  26395. export class StandardMaterial extends PushMaterial {
  26396. private _diffuseTexture;
  26397. /**
  26398. * The basic texture of the material as viewed under a light.
  26399. */
  26400. diffuseTexture: Nullable<BaseTexture>;
  26401. private _ambientTexture;
  26402. /**
  26403. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26404. */
  26405. ambientTexture: Nullable<BaseTexture>;
  26406. private _opacityTexture;
  26407. /**
  26408. * Define the transparency of the material from a texture.
  26409. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26410. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26411. */
  26412. opacityTexture: Nullable<BaseTexture>;
  26413. private _reflectionTexture;
  26414. /**
  26415. * Define the texture used to display the reflection.
  26416. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26417. */
  26418. reflectionTexture: Nullable<BaseTexture>;
  26419. private _emissiveTexture;
  26420. /**
  26421. * Define texture of the material as if self lit.
  26422. * This will be mixed in the final result even in the absence of light.
  26423. */
  26424. emissiveTexture: Nullable<BaseTexture>;
  26425. private _specularTexture;
  26426. /**
  26427. * Define how the color and intensity of the highlight given by the light in the material.
  26428. */
  26429. specularTexture: Nullable<BaseTexture>;
  26430. private _bumpTexture;
  26431. /**
  26432. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26433. * 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.
  26434. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26435. */
  26436. bumpTexture: Nullable<BaseTexture>;
  26437. private _lightmapTexture;
  26438. /**
  26439. * Complex lighting can be computationally expensive to compute at runtime.
  26440. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26441. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26442. */
  26443. lightmapTexture: Nullable<BaseTexture>;
  26444. private _refractionTexture;
  26445. /**
  26446. * Define the texture used to display the refraction.
  26447. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26448. */
  26449. refractionTexture: Nullable<BaseTexture>;
  26450. /**
  26451. * The color of the material lit by the environmental background lighting.
  26452. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26453. */
  26454. ambientColor: Color3;
  26455. /**
  26456. * The basic color of the material as viewed under a light.
  26457. */
  26458. diffuseColor: Color3;
  26459. /**
  26460. * Define how the color and intensity of the highlight given by the light in the material.
  26461. */
  26462. specularColor: Color3;
  26463. /**
  26464. * Define the color of the material as if self lit.
  26465. * This will be mixed in the final result even in the absence of light.
  26466. */
  26467. emissiveColor: Color3;
  26468. /**
  26469. * Defines how sharp are the highlights in the material.
  26470. * The bigger the value the sharper giving a more glossy feeling to the result.
  26471. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26472. */
  26473. specularPower: number;
  26474. private _useAlphaFromDiffuseTexture;
  26475. /**
  26476. * Does the transparency come from the diffuse texture alpha channel.
  26477. */
  26478. useAlphaFromDiffuseTexture: boolean;
  26479. private _useEmissiveAsIllumination;
  26480. /**
  26481. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26482. */
  26483. useEmissiveAsIllumination: boolean;
  26484. private _linkEmissiveWithDiffuse;
  26485. /**
  26486. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26487. * the emissive level when the final color is close to one.
  26488. */
  26489. linkEmissiveWithDiffuse: boolean;
  26490. private _useSpecularOverAlpha;
  26491. /**
  26492. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26493. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26494. */
  26495. useSpecularOverAlpha: boolean;
  26496. private _useReflectionOverAlpha;
  26497. /**
  26498. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26499. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26500. */
  26501. useReflectionOverAlpha: boolean;
  26502. private _disableLighting;
  26503. /**
  26504. * Does lights from the scene impacts this material.
  26505. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26506. */
  26507. disableLighting: boolean;
  26508. private _useObjectSpaceNormalMap;
  26509. /**
  26510. * Allows using an object space normal map (instead of tangent space).
  26511. */
  26512. useObjectSpaceNormalMap: boolean;
  26513. private _useParallax;
  26514. /**
  26515. * Is parallax enabled or not.
  26516. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26517. */
  26518. useParallax: boolean;
  26519. private _useParallaxOcclusion;
  26520. /**
  26521. * Is parallax occlusion enabled or not.
  26522. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26523. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26524. */
  26525. useParallaxOcclusion: boolean;
  26526. /**
  26527. * 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.
  26528. */
  26529. parallaxScaleBias: number;
  26530. private _roughness;
  26531. /**
  26532. * Helps to define how blurry the reflections should appears in the material.
  26533. */
  26534. roughness: number;
  26535. /**
  26536. * In case of refraction, define the value of the index of refraction.
  26537. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26538. */
  26539. indexOfRefraction: number;
  26540. /**
  26541. * Invert the refraction texture alongside the y axis.
  26542. * It can be useful with procedural textures or probe for instance.
  26543. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26544. */
  26545. invertRefractionY: boolean;
  26546. /**
  26547. * Defines the alpha limits in alpha test mode.
  26548. */
  26549. alphaCutOff: number;
  26550. private _useLightmapAsShadowmap;
  26551. /**
  26552. * In case of light mapping, define whether the map contains light or shadow informations.
  26553. */
  26554. useLightmapAsShadowmap: boolean;
  26555. private _diffuseFresnelParameters;
  26556. /**
  26557. * Define the diffuse fresnel parameters of the material.
  26558. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26559. */
  26560. diffuseFresnelParameters: FresnelParameters;
  26561. private _opacityFresnelParameters;
  26562. /**
  26563. * Define the opacity fresnel parameters of the material.
  26564. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26565. */
  26566. opacityFresnelParameters: FresnelParameters;
  26567. private _reflectionFresnelParameters;
  26568. /**
  26569. * Define the reflection fresnel parameters of the material.
  26570. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26571. */
  26572. reflectionFresnelParameters: FresnelParameters;
  26573. private _refractionFresnelParameters;
  26574. /**
  26575. * Define the refraction fresnel parameters of the material.
  26576. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26577. */
  26578. refractionFresnelParameters: FresnelParameters;
  26579. private _emissiveFresnelParameters;
  26580. /**
  26581. * Define the emissive fresnel parameters of the material.
  26582. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26583. */
  26584. emissiveFresnelParameters: FresnelParameters;
  26585. private _useReflectionFresnelFromSpecular;
  26586. /**
  26587. * If true automatically deducts the fresnels values from the material specularity.
  26588. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26589. */
  26590. useReflectionFresnelFromSpecular: boolean;
  26591. private _useGlossinessFromSpecularMapAlpha;
  26592. /**
  26593. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26594. */
  26595. useGlossinessFromSpecularMapAlpha: boolean;
  26596. private _maxSimultaneousLights;
  26597. /**
  26598. * Defines the maximum number of lights that can be used in the material
  26599. */
  26600. maxSimultaneousLights: number;
  26601. private _invertNormalMapX;
  26602. /**
  26603. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26604. */
  26605. invertNormalMapX: boolean;
  26606. private _invertNormalMapY;
  26607. /**
  26608. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26609. */
  26610. invertNormalMapY: boolean;
  26611. private _twoSidedLighting;
  26612. /**
  26613. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26614. */
  26615. twoSidedLighting: boolean;
  26616. /**
  26617. * Default configuration related to image processing available in the standard Material.
  26618. */
  26619. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26620. /**
  26621. * Gets the image processing configuration used either in this material.
  26622. */
  26623. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26624. /**
  26625. * Sets the Default image processing configuration used either in the this material.
  26626. *
  26627. * If sets to null, the scene one is in use.
  26628. */
  26629. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26630. /**
  26631. * Keep track of the image processing observer to allow dispose and replace.
  26632. */
  26633. private _imageProcessingObserver;
  26634. /**
  26635. * Attaches a new image processing configuration to the Standard Material.
  26636. * @param configuration
  26637. */
  26638. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26639. /**
  26640. * Gets wether the color curves effect is enabled.
  26641. */
  26642. get cameraColorCurvesEnabled(): boolean;
  26643. /**
  26644. * Sets wether the color curves effect is enabled.
  26645. */
  26646. set cameraColorCurvesEnabled(value: boolean);
  26647. /**
  26648. * Gets wether the color grading effect is enabled.
  26649. */
  26650. get cameraColorGradingEnabled(): boolean;
  26651. /**
  26652. * Gets wether the color grading effect is enabled.
  26653. */
  26654. set cameraColorGradingEnabled(value: boolean);
  26655. /**
  26656. * Gets wether tonemapping is enabled or not.
  26657. */
  26658. get cameraToneMappingEnabled(): boolean;
  26659. /**
  26660. * Sets wether tonemapping is enabled or not
  26661. */
  26662. set cameraToneMappingEnabled(value: boolean);
  26663. /**
  26664. * The camera exposure used on this material.
  26665. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26666. * This corresponds to a photographic exposure.
  26667. */
  26668. get cameraExposure(): number;
  26669. /**
  26670. * The camera exposure used on this material.
  26671. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26672. * This corresponds to a photographic exposure.
  26673. */
  26674. set cameraExposure(value: number);
  26675. /**
  26676. * Gets The camera contrast used on this material.
  26677. */
  26678. get cameraContrast(): number;
  26679. /**
  26680. * Sets The camera contrast used on this material.
  26681. */
  26682. set cameraContrast(value: number);
  26683. /**
  26684. * Gets the Color Grading 2D Lookup Texture.
  26685. */
  26686. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26687. /**
  26688. * Sets the Color Grading 2D Lookup Texture.
  26689. */
  26690. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26691. /**
  26692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26694. * 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;
  26695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26696. */
  26697. get cameraColorCurves(): Nullable<ColorCurves>;
  26698. /**
  26699. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26700. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26701. * 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;
  26702. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26703. */
  26704. set cameraColorCurves(value: Nullable<ColorCurves>);
  26705. /**
  26706. * Custom callback helping to override the default shader used in the material.
  26707. */
  26708. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26709. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26710. protected _worldViewProjectionMatrix: Matrix;
  26711. protected _globalAmbientColor: Color3;
  26712. protected _useLogarithmicDepth: boolean;
  26713. protected _rebuildInParallel: boolean;
  26714. /**
  26715. * Instantiates a new standard material.
  26716. * This is the default material used in Babylon. It is the best trade off between quality
  26717. * and performances.
  26718. * @see http://doc.babylonjs.com/babylon101/materials
  26719. * @param name Define the name of the material in the scene
  26720. * @param scene Define the scene the material belong to
  26721. */
  26722. constructor(name: string, scene: Scene);
  26723. /**
  26724. * Gets a boolean indicating that current material needs to register RTT
  26725. */
  26726. get hasRenderTargetTextures(): boolean;
  26727. /**
  26728. * Gets the current class name of the material e.g. "StandardMaterial"
  26729. * Mainly use in serialization.
  26730. * @returns the class name
  26731. */
  26732. getClassName(): string;
  26733. /**
  26734. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26735. * You can try switching to logarithmic depth.
  26736. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26737. */
  26738. get useLogarithmicDepth(): boolean;
  26739. set useLogarithmicDepth(value: boolean);
  26740. /**
  26741. * Specifies if the material will require alpha blending
  26742. * @returns a boolean specifying if alpha blending is needed
  26743. */
  26744. needAlphaBlending(): boolean;
  26745. /**
  26746. * Specifies if this material should be rendered in alpha test mode
  26747. * @returns a boolean specifying if an alpha test is needed.
  26748. */
  26749. needAlphaTesting(): boolean;
  26750. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26751. /**
  26752. * Get the texture used for alpha test purpose.
  26753. * @returns the diffuse texture in case of the standard material.
  26754. */
  26755. getAlphaTestTexture(): Nullable<BaseTexture>;
  26756. /**
  26757. * Get if the submesh is ready to be used and all its information available.
  26758. * Child classes can use it to update shaders
  26759. * @param mesh defines the mesh to check
  26760. * @param subMesh defines which submesh to check
  26761. * @param useInstances specifies that instances should be used
  26762. * @returns a boolean indicating that the submesh is ready or not
  26763. */
  26764. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26765. /**
  26766. * Builds the material UBO layouts.
  26767. * Used internally during the effect preparation.
  26768. */
  26769. buildUniformLayout(): void;
  26770. /**
  26771. * Unbinds the material from the mesh
  26772. */
  26773. unbind(): void;
  26774. /**
  26775. * Binds the submesh to this material by preparing the effect and shader to draw
  26776. * @param world defines the world transformation matrix
  26777. * @param mesh defines the mesh containing the submesh
  26778. * @param subMesh defines the submesh to bind the material to
  26779. */
  26780. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26781. /**
  26782. * Get the list of animatables in the material.
  26783. * @returns the list of animatables object used in the material
  26784. */
  26785. getAnimatables(): IAnimatable[];
  26786. /**
  26787. * Gets the active textures from the material
  26788. * @returns an array of textures
  26789. */
  26790. getActiveTextures(): BaseTexture[];
  26791. /**
  26792. * Specifies if the material uses a texture
  26793. * @param texture defines the texture to check against the material
  26794. * @returns a boolean specifying if the material uses the texture
  26795. */
  26796. hasTexture(texture: BaseTexture): boolean;
  26797. /**
  26798. * Disposes the material
  26799. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26800. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26801. */
  26802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26803. /**
  26804. * Makes a duplicate of the material, and gives it a new name
  26805. * @param name defines the new name for the duplicated material
  26806. * @returns the cloned material
  26807. */
  26808. clone(name: string): StandardMaterial;
  26809. /**
  26810. * Serializes this material in a JSON representation
  26811. * @returns the serialized material object
  26812. */
  26813. serialize(): any;
  26814. /**
  26815. * Creates a standard material from parsed material data
  26816. * @param source defines the JSON representation of the material
  26817. * @param scene defines the hosting scene
  26818. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26819. * @returns a new standard material
  26820. */
  26821. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26822. /**
  26823. * Are diffuse textures enabled in the application.
  26824. */
  26825. static get DiffuseTextureEnabled(): boolean;
  26826. static set DiffuseTextureEnabled(value: boolean);
  26827. /**
  26828. * Are ambient textures enabled in the application.
  26829. */
  26830. static get AmbientTextureEnabled(): boolean;
  26831. static set AmbientTextureEnabled(value: boolean);
  26832. /**
  26833. * Are opacity textures enabled in the application.
  26834. */
  26835. static get OpacityTextureEnabled(): boolean;
  26836. static set OpacityTextureEnabled(value: boolean);
  26837. /**
  26838. * Are reflection textures enabled in the application.
  26839. */
  26840. static get ReflectionTextureEnabled(): boolean;
  26841. static set ReflectionTextureEnabled(value: boolean);
  26842. /**
  26843. * Are emissive textures enabled in the application.
  26844. */
  26845. static get EmissiveTextureEnabled(): boolean;
  26846. static set EmissiveTextureEnabled(value: boolean);
  26847. /**
  26848. * Are specular textures enabled in the application.
  26849. */
  26850. static get SpecularTextureEnabled(): boolean;
  26851. static set SpecularTextureEnabled(value: boolean);
  26852. /**
  26853. * Are bump textures enabled in the application.
  26854. */
  26855. static get BumpTextureEnabled(): boolean;
  26856. static set BumpTextureEnabled(value: boolean);
  26857. /**
  26858. * Are lightmap textures enabled in the application.
  26859. */
  26860. static get LightmapTextureEnabled(): boolean;
  26861. static set LightmapTextureEnabled(value: boolean);
  26862. /**
  26863. * Are refraction textures enabled in the application.
  26864. */
  26865. static get RefractionTextureEnabled(): boolean;
  26866. static set RefractionTextureEnabled(value: boolean);
  26867. /**
  26868. * Are color grading textures enabled in the application.
  26869. */
  26870. static get ColorGradingTextureEnabled(): boolean;
  26871. static set ColorGradingTextureEnabled(value: boolean);
  26872. /**
  26873. * Are fresnels enabled in the application.
  26874. */
  26875. static get FresnelEnabled(): boolean;
  26876. static set FresnelEnabled(value: boolean);
  26877. }
  26878. }
  26879. declare module BABYLON {
  26880. /**
  26881. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26882. *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.
  26883. * The SPS is also a particle system. It provides some methods to manage the particles.
  26884. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26885. *
  26886. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26887. */
  26888. export class SolidParticleSystem implements IDisposable {
  26889. /**
  26890. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26891. * Example : var p = SPS.particles[i];
  26892. */
  26893. particles: SolidParticle[];
  26894. /**
  26895. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26896. */
  26897. nbParticles: number;
  26898. /**
  26899. * If the particles must ever face the camera (default false). Useful for planar particles.
  26900. */
  26901. billboard: boolean;
  26902. /**
  26903. * Recompute normals when adding a shape
  26904. */
  26905. recomputeNormals: boolean;
  26906. /**
  26907. * This a counter ofr your own usage. It's not set by any SPS functions.
  26908. */
  26909. counter: number;
  26910. /**
  26911. * The SPS name. This name is also given to the underlying mesh.
  26912. */
  26913. name: string;
  26914. /**
  26915. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26916. */
  26917. mesh: Mesh;
  26918. /**
  26919. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26920. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26921. */
  26922. vars: any;
  26923. /**
  26924. * This array is populated when the SPS is set as 'pickable'.
  26925. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26926. * Each element of this array is an object `{idx: int, faceId: int}`.
  26927. * `idx` is the picked particle index in the `SPS.particles` array
  26928. * `faceId` is the picked face index counted within this particle.
  26929. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26930. */
  26931. pickedParticles: {
  26932. idx: number;
  26933. faceId: number;
  26934. }[];
  26935. /**
  26936. * This array is populated when `enableDepthSort` is set to true.
  26937. * Each element of this array is an instance of the class DepthSortedParticle.
  26938. */
  26939. depthSortedParticles: DepthSortedParticle[];
  26940. /**
  26941. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26942. * @hidden
  26943. */
  26944. _bSphereOnly: boolean;
  26945. /**
  26946. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26947. * @hidden
  26948. */
  26949. _bSphereRadiusFactor: number;
  26950. private _scene;
  26951. private _positions;
  26952. private _indices;
  26953. private _normals;
  26954. private _colors;
  26955. private _uvs;
  26956. private _indices32;
  26957. private _positions32;
  26958. private _normals32;
  26959. private _fixedNormal32;
  26960. private _colors32;
  26961. private _uvs32;
  26962. private _index;
  26963. private _updatable;
  26964. private _pickable;
  26965. private _isVisibilityBoxLocked;
  26966. private _alwaysVisible;
  26967. private _depthSort;
  26968. private _expandable;
  26969. private _shapeCounter;
  26970. private _copy;
  26971. private _color;
  26972. private _computeParticleColor;
  26973. private _computeParticleTexture;
  26974. private _computeParticleRotation;
  26975. private _computeParticleVertex;
  26976. private _computeBoundingBox;
  26977. private _depthSortParticles;
  26978. private _camera;
  26979. private _mustUnrotateFixedNormals;
  26980. private _particlesIntersect;
  26981. private _needs32Bits;
  26982. private _isNotBuilt;
  26983. private _lastParticleId;
  26984. private _idxOfId;
  26985. private _multimaterialEnabled;
  26986. private _useModelMaterial;
  26987. private _indicesByMaterial;
  26988. private _materialIndexes;
  26989. private _depthSortFunction;
  26990. private _materialSortFunction;
  26991. private _materials;
  26992. private _multimaterial;
  26993. private _materialIndexesById;
  26994. private _defaultMaterial;
  26995. private _autoUpdateSubMeshes;
  26996. /**
  26997. * Creates a SPS (Solid Particle System) object.
  26998. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26999. * @param scene (Scene) is the scene in which the SPS is added.
  27000. * @param options defines the options of the sps e.g.
  27001. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27002. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27003. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27004. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27005. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27006. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27007. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27008. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27009. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27010. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27011. */
  27012. constructor(name: string, scene: Scene, options?: {
  27013. updatable?: boolean;
  27014. isPickable?: boolean;
  27015. enableDepthSort?: boolean;
  27016. particleIntersection?: boolean;
  27017. boundingSphereOnly?: boolean;
  27018. bSphereRadiusFactor?: number;
  27019. expandable?: boolean;
  27020. useModelMaterial?: boolean;
  27021. enableMultiMaterial?: boolean;
  27022. });
  27023. /**
  27024. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27025. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27026. * @returns the created mesh
  27027. */
  27028. buildMesh(): Mesh;
  27029. /**
  27030. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27031. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27032. * Thus the particles generated from `digest()` have their property `position` set yet.
  27033. * @param mesh ( Mesh ) is the mesh to be digested
  27034. * @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
  27035. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27036. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27037. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27038. * @returns the current SPS
  27039. */
  27040. digest(mesh: Mesh, options?: {
  27041. facetNb?: number;
  27042. number?: number;
  27043. delta?: number;
  27044. storage?: [];
  27045. }): SolidParticleSystem;
  27046. /**
  27047. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27048. * @hidden
  27049. */
  27050. private _unrotateFixedNormals;
  27051. /**
  27052. * Resets the temporary working copy particle
  27053. * @hidden
  27054. */
  27055. private _resetCopy;
  27056. /**
  27057. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27058. * @param p the current index in the positions array to be updated
  27059. * @param ind the current index in the indices array
  27060. * @param shape a Vector3 array, the shape geometry
  27061. * @param positions the positions array to be updated
  27062. * @param meshInd the shape indices array
  27063. * @param indices the indices array to be updated
  27064. * @param meshUV the shape uv array
  27065. * @param uvs the uv array to be updated
  27066. * @param meshCol the shape color array
  27067. * @param colors the color array to be updated
  27068. * @param meshNor the shape normals array
  27069. * @param normals the normals array to be updated
  27070. * @param idx the particle index
  27071. * @param idxInShape the particle index in its shape
  27072. * @param options the addShape() method passed options
  27073. * @model the particle model
  27074. * @hidden
  27075. */
  27076. private _meshBuilder;
  27077. /**
  27078. * Returns a shape Vector3 array from positions float array
  27079. * @param positions float array
  27080. * @returns a vector3 array
  27081. * @hidden
  27082. */
  27083. private _posToShape;
  27084. /**
  27085. * Returns a shapeUV array from a float uvs (array deep copy)
  27086. * @param uvs as a float array
  27087. * @returns a shapeUV array
  27088. * @hidden
  27089. */
  27090. private _uvsToShapeUV;
  27091. /**
  27092. * Adds a new particle object in the particles array
  27093. * @param idx particle index in particles array
  27094. * @param id particle id
  27095. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27096. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27097. * @param model particle ModelShape object
  27098. * @param shapeId model shape identifier
  27099. * @param idxInShape index of the particle in the current model
  27100. * @param bInfo model bounding info object
  27101. * @param storage target storage array, if any
  27102. * @hidden
  27103. */
  27104. private _addParticle;
  27105. /**
  27106. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27107. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27108. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27109. * @param nb (positive integer) the number of particles to be created from this model
  27110. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27111. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27112. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27113. * @returns the number of shapes in the system
  27114. */
  27115. addShape(mesh: Mesh, nb: number, options?: {
  27116. positionFunction?: any;
  27117. vertexFunction?: any;
  27118. storage?: [];
  27119. }): number;
  27120. /**
  27121. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27122. * @hidden
  27123. */
  27124. private _rebuildParticle;
  27125. /**
  27126. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27127. * @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.
  27128. * @returns the SPS.
  27129. */
  27130. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27131. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27132. * Returns an array with the removed particles.
  27133. * 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.
  27134. * The SPS can't be empty so at least one particle needs to remain in place.
  27135. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27136. * @param start index of the first particle to remove
  27137. * @param end index of the last particle to remove (included)
  27138. * @returns an array populated with the removed particles
  27139. */
  27140. removeParticles(start: number, end: number): SolidParticle[];
  27141. /**
  27142. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27143. * @param solidParticleArray an array populated with Solid Particles objects
  27144. * @returns the SPS
  27145. */
  27146. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27147. /**
  27148. * Creates a new particle and modifies the SPS mesh geometry :
  27149. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27150. * - calls _addParticle() to populate the particle array
  27151. * factorized code from addShape() and insertParticlesFromArray()
  27152. * @param idx particle index in the particles array
  27153. * @param i particle index in its shape
  27154. * @param modelShape particle ModelShape object
  27155. * @param shape shape vertex array
  27156. * @param meshInd shape indices array
  27157. * @param meshUV shape uv array
  27158. * @param meshCol shape color array
  27159. * @param meshNor shape normals array
  27160. * @param bbInfo shape bounding info
  27161. * @param storage target particle storage
  27162. * @options addShape() passed options
  27163. * @hidden
  27164. */
  27165. private _insertNewParticle;
  27166. /**
  27167. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27168. * This method calls `updateParticle()` for each particle of the SPS.
  27169. * For an animated SPS, it is usually called within the render loop.
  27170. * 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.
  27171. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27172. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27173. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27174. * @returns the SPS.
  27175. */
  27176. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27177. /**
  27178. * Disposes the SPS.
  27179. */
  27180. dispose(): void;
  27181. /**
  27182. * Returns a SolidParticle object from its identifier : particle.id
  27183. * @param id (integer) the particle Id
  27184. * @returns the searched particle or null if not found in the SPS.
  27185. */
  27186. getParticleById(id: number): Nullable<SolidParticle>;
  27187. /**
  27188. * Returns a new array populated with the particles having the passed shapeId.
  27189. * @param shapeId (integer) the shape identifier
  27190. * @returns a new solid particle array
  27191. */
  27192. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27193. /**
  27194. * Populates the passed array "ref" with the particles having the passed shapeId.
  27195. * @param shapeId the shape identifier
  27196. * @returns the SPS
  27197. * @param ref
  27198. */
  27199. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27200. /**
  27201. * Computes the required SubMeshes according the materials assigned to the particles.
  27202. * @returns the solid particle system.
  27203. * Does nothing if called before the SPS mesh is built.
  27204. */
  27205. computeSubMeshes(): SolidParticleSystem;
  27206. /**
  27207. * Sorts the solid particles by material when MultiMaterial is enabled.
  27208. * Updates the indices32 array.
  27209. * Updates the indicesByMaterial array.
  27210. * Updates the mesh indices array.
  27211. * @returns the SPS
  27212. * @hidden
  27213. */
  27214. private _sortParticlesByMaterial;
  27215. /**
  27216. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27217. * @hidden
  27218. */
  27219. private _setMaterialIndexesById;
  27220. /**
  27221. * Returns an array with unique values of Materials from the passed array
  27222. * @param array the material array to be checked and filtered
  27223. * @hidden
  27224. */
  27225. private _filterUniqueMaterialId;
  27226. /**
  27227. * Sets a new Standard Material as _defaultMaterial if not already set.
  27228. * @hidden
  27229. */
  27230. private _setDefaultMaterial;
  27231. /**
  27232. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27234. * @returns the SPS.
  27235. */
  27236. refreshVisibleSize(): SolidParticleSystem;
  27237. /**
  27238. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27239. * @param size the size (float) of the visibility box
  27240. * note : this doesn't lock the SPS mesh bounding box.
  27241. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27242. */
  27243. setVisibilityBox(size: number): void;
  27244. /**
  27245. * Gets whether the SPS as always visible or not
  27246. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27247. */
  27248. get isAlwaysVisible(): boolean;
  27249. /**
  27250. * Sets the SPS as always visible or not
  27251. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27252. */
  27253. set isAlwaysVisible(val: boolean);
  27254. /**
  27255. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27256. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27257. */
  27258. set isVisibilityBoxLocked(val: boolean);
  27259. /**
  27260. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27261. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27262. */
  27263. get isVisibilityBoxLocked(): boolean;
  27264. /**
  27265. * Tells to `setParticles()` to compute the particle rotations or not.
  27266. * Default value : true. The SPS is faster when it's set to false.
  27267. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27268. */
  27269. set computeParticleRotation(val: boolean);
  27270. /**
  27271. * Tells to `setParticles()` to compute the particle colors or not.
  27272. * Default value : true. The SPS is faster when it's set to false.
  27273. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27274. */
  27275. set computeParticleColor(val: boolean);
  27276. set computeParticleTexture(val: boolean);
  27277. /**
  27278. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27279. * Default value : false. The SPS is faster when it's set to false.
  27280. * Note : the particle custom vertex positions aren't stored values.
  27281. */
  27282. set computeParticleVertex(val: boolean);
  27283. /**
  27284. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27285. */
  27286. set computeBoundingBox(val: boolean);
  27287. /**
  27288. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27289. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27290. * Default : `true`
  27291. */
  27292. set depthSortParticles(val: boolean);
  27293. /**
  27294. * Gets if `setParticles()` computes the particle rotations or not.
  27295. * Default value : true. The SPS is faster when it's set to false.
  27296. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27297. */
  27298. get computeParticleRotation(): boolean;
  27299. /**
  27300. * Gets if `setParticles()` computes the particle colors or not.
  27301. * Default value : true. The SPS is faster when it's set to false.
  27302. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27303. */
  27304. get computeParticleColor(): boolean;
  27305. /**
  27306. * Gets if `setParticles()` computes the particle textures or not.
  27307. * Default value : true. The SPS is faster when it's set to false.
  27308. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27309. */
  27310. get computeParticleTexture(): boolean;
  27311. /**
  27312. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27313. * Default value : false. The SPS is faster when it's set to false.
  27314. * Note : the particle custom vertex positions aren't stored values.
  27315. */
  27316. get computeParticleVertex(): boolean;
  27317. /**
  27318. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27319. */
  27320. get computeBoundingBox(): boolean;
  27321. /**
  27322. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27323. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27324. * Default : `true`
  27325. */
  27326. get depthSortParticles(): boolean;
  27327. /**
  27328. * Gets if the SPS is created as expandable at construction time.
  27329. * Default : `false`
  27330. */
  27331. get expandable(): boolean;
  27332. /**
  27333. * Gets if the SPS supports the Multi Materials
  27334. */
  27335. get multimaterialEnabled(): boolean;
  27336. /**
  27337. * Gets if the SPS uses the model materials for its own multimaterial.
  27338. */
  27339. get useModelMaterial(): boolean;
  27340. /**
  27341. * The SPS used material array.
  27342. */
  27343. get materials(): Material[];
  27344. /**
  27345. * Sets the SPS MultiMaterial from the passed materials.
  27346. * Note : the passed array is internally copied and not used then by reference.
  27347. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27348. */
  27349. setMultiMaterial(materials: Material[]): void;
  27350. /**
  27351. * The SPS computed multimaterial object
  27352. */
  27353. get multimaterial(): MultiMaterial;
  27354. set multimaterial(mm: MultiMaterial);
  27355. /**
  27356. * If the subMeshes must be updated on the next call to setParticles()
  27357. */
  27358. get autoUpdateSubMeshes(): boolean;
  27359. set autoUpdateSubMeshes(val: boolean);
  27360. /**
  27361. * This function does nothing. It may be overwritten to set all the particle first values.
  27362. * The SPS doesn't call this function, you may have to call it by your own.
  27363. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27364. */
  27365. initParticles(): void;
  27366. /**
  27367. * This function does nothing. It may be overwritten to recycle a particle.
  27368. * The SPS doesn't call this function, you may have to call it by your own.
  27369. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27370. * @param particle The particle to recycle
  27371. * @returns the recycled particle
  27372. */
  27373. recycleParticle(particle: SolidParticle): SolidParticle;
  27374. /**
  27375. * Updates a particle : this function should be overwritten by the user.
  27376. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27377. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27378. * @example : just set a particle position or velocity and recycle conditions
  27379. * @param particle The particle to update
  27380. * @returns the updated particle
  27381. */
  27382. updateParticle(particle: SolidParticle): SolidParticle;
  27383. /**
  27384. * Updates a vertex of a particle : it can be overwritten by the user.
  27385. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27386. * @param particle the current particle
  27387. * @param vertex the current index of the current particle
  27388. * @param pt the index of the current vertex in the particle shape
  27389. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27390. * @example : just set a vertex particle position
  27391. * @returns the updated vertex
  27392. */
  27393. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27394. /**
  27395. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27396. * This does nothing and may be overwritten by the user.
  27397. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27398. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27399. * @param update the boolean update value actually passed to setParticles()
  27400. */
  27401. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27402. /**
  27403. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27404. * This will be passed three parameters.
  27405. * This does nothing and may be overwritten by the user.
  27406. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27407. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27408. * @param update the boolean update value actually passed to setParticles()
  27409. */
  27410. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27411. }
  27412. }
  27413. declare module BABYLON {
  27414. /**
  27415. * Represents one particle of a solid particle system.
  27416. */
  27417. export class SolidParticle {
  27418. /**
  27419. * particle global index
  27420. */
  27421. idx: number;
  27422. /**
  27423. * particle identifier
  27424. */
  27425. id: number;
  27426. /**
  27427. * The color of the particle
  27428. */
  27429. color: Nullable<Color4>;
  27430. /**
  27431. * The world space position of the particle.
  27432. */
  27433. position: Vector3;
  27434. /**
  27435. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27436. */
  27437. rotation: Vector3;
  27438. /**
  27439. * The world space rotation quaternion of the particle.
  27440. */
  27441. rotationQuaternion: Nullable<Quaternion>;
  27442. /**
  27443. * The scaling of the particle.
  27444. */
  27445. scaling: Vector3;
  27446. /**
  27447. * The uvs of the particle.
  27448. */
  27449. uvs: Vector4;
  27450. /**
  27451. * The current speed of the particle.
  27452. */
  27453. velocity: Vector3;
  27454. /**
  27455. * The pivot point in the particle local space.
  27456. */
  27457. pivot: Vector3;
  27458. /**
  27459. * Must the particle be translated from its pivot point in its local space ?
  27460. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27461. * Default : false
  27462. */
  27463. translateFromPivot: boolean;
  27464. /**
  27465. * Is the particle active or not ?
  27466. */
  27467. alive: boolean;
  27468. /**
  27469. * Is the particle visible or not ?
  27470. */
  27471. isVisible: boolean;
  27472. /**
  27473. * Index of this particle in the global "positions" array (Internal use)
  27474. * @hidden
  27475. */
  27476. _pos: number;
  27477. /**
  27478. * @hidden Index of this particle in the global "indices" array (Internal use)
  27479. */
  27480. _ind: number;
  27481. /**
  27482. * @hidden ModelShape of this particle (Internal use)
  27483. */
  27484. _model: ModelShape;
  27485. /**
  27486. * ModelShape id of this particle
  27487. */
  27488. shapeId: number;
  27489. /**
  27490. * Index of the particle in its shape id
  27491. */
  27492. idxInShape: number;
  27493. /**
  27494. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27495. */
  27496. _modelBoundingInfo: BoundingInfo;
  27497. /**
  27498. * @hidden Particle BoundingInfo object (Internal use)
  27499. */
  27500. _boundingInfo: BoundingInfo;
  27501. /**
  27502. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27503. */
  27504. _sps: SolidParticleSystem;
  27505. /**
  27506. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27507. */
  27508. _stillInvisible: boolean;
  27509. /**
  27510. * @hidden Last computed particle rotation matrix
  27511. */
  27512. _rotationMatrix: number[];
  27513. /**
  27514. * Parent particle Id, if any.
  27515. * Default null.
  27516. */
  27517. parentId: Nullable<number>;
  27518. /**
  27519. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27520. */
  27521. materialIndex: Nullable<number>;
  27522. /**
  27523. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27524. * The possible values are :
  27525. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27526. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27527. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27528. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27529. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27530. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27531. * */
  27532. cullingStrategy: number;
  27533. /**
  27534. * @hidden Internal global position in the SPS.
  27535. */
  27536. _globalPosition: Vector3;
  27537. /**
  27538. * Creates a Solid Particle object.
  27539. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27540. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27541. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27542. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27543. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27544. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27545. * @param shapeId (integer) is the model shape identifier in the SPS.
  27546. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27547. * @param sps defines the sps it is associated to
  27548. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27549. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27550. */
  27551. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27552. /**
  27553. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27554. * @param target the particle target
  27555. * @returns the current particle
  27556. */
  27557. copyToRef(target: SolidParticle): SolidParticle;
  27558. /**
  27559. * Legacy support, changed scale to scaling
  27560. */
  27561. get scale(): Vector3;
  27562. /**
  27563. * Legacy support, changed scale to scaling
  27564. */
  27565. set scale(scale: Vector3);
  27566. /**
  27567. * Legacy support, changed quaternion to rotationQuaternion
  27568. */
  27569. get quaternion(): Nullable<Quaternion>;
  27570. /**
  27571. * Legacy support, changed quaternion to rotationQuaternion
  27572. */
  27573. set quaternion(q: Nullable<Quaternion>);
  27574. /**
  27575. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27576. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27577. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27578. * @returns true if it intersects
  27579. */
  27580. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27581. /**
  27582. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27583. * A particle is in the frustum if its bounding box intersects the frustum
  27584. * @param frustumPlanes defines the frustum to test
  27585. * @returns true if the particle is in the frustum planes
  27586. */
  27587. isInFrustum(frustumPlanes: Plane[]): boolean;
  27588. /**
  27589. * get the rotation matrix of the particle
  27590. * @hidden
  27591. */
  27592. getRotationMatrix(m: Matrix): void;
  27593. }
  27594. /**
  27595. * Represents the shape of the model used by one particle of a solid particle system.
  27596. * SPS internal tool, don't use it manually.
  27597. */
  27598. export class ModelShape {
  27599. /**
  27600. * The shape id
  27601. * @hidden
  27602. */
  27603. shapeID: number;
  27604. /**
  27605. * flat array of model positions (internal use)
  27606. * @hidden
  27607. */
  27608. _shape: Vector3[];
  27609. /**
  27610. * flat array of model UVs (internal use)
  27611. * @hidden
  27612. */
  27613. _shapeUV: number[];
  27614. /**
  27615. * color array of the model
  27616. * @hidden
  27617. */
  27618. _shapeColors: number[];
  27619. /**
  27620. * indices array of the model
  27621. * @hidden
  27622. */
  27623. _indices: number[];
  27624. /**
  27625. * normals array of the model
  27626. * @hidden
  27627. */
  27628. _normals: number[];
  27629. /**
  27630. * length of the shape in the model indices array (internal use)
  27631. * @hidden
  27632. */
  27633. _indicesLength: number;
  27634. /**
  27635. * Custom position function (internal use)
  27636. * @hidden
  27637. */
  27638. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27639. /**
  27640. * Custom vertex function (internal use)
  27641. * @hidden
  27642. */
  27643. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27644. /**
  27645. * Model material (internal use)
  27646. * @hidden
  27647. */
  27648. _material: Nullable<Material>;
  27649. /**
  27650. * 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.
  27651. * SPS internal tool, don't use it manually.
  27652. * @hidden
  27653. */
  27654. 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>, material: Nullable<Material>);
  27655. }
  27656. /**
  27657. * Represents a Depth Sorted Particle in the solid particle system.
  27658. * @hidden
  27659. */
  27660. export class DepthSortedParticle {
  27661. /**
  27662. * Index of the particle in the "indices" array
  27663. */
  27664. ind: number;
  27665. /**
  27666. * Length of the particle shape in the "indices" array
  27667. */
  27668. indicesLength: number;
  27669. /**
  27670. * Squared distance from the particle to the camera
  27671. */
  27672. sqDistance: number;
  27673. /**
  27674. * Material index when used with MultiMaterials
  27675. */
  27676. materialIndex: number;
  27677. /**
  27678. * Creates a new sorted particle
  27679. * @param materialIndex
  27680. */
  27681. constructor(ind: number, indLength: number, materialIndex: number);
  27682. }
  27683. }
  27684. declare module BABYLON {
  27685. /**
  27686. * @hidden
  27687. */
  27688. export class _MeshCollisionData {
  27689. _checkCollisions: boolean;
  27690. _collisionMask: number;
  27691. _collisionGroup: number;
  27692. _collider: Nullable<Collider>;
  27693. _oldPositionForCollisions: Vector3;
  27694. _diffPositionForCollisions: Vector3;
  27695. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27696. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27697. }
  27698. }
  27699. declare module BABYLON {
  27700. /** @hidden */
  27701. class _FacetDataStorage {
  27702. facetPositions: Vector3[];
  27703. facetNormals: Vector3[];
  27704. facetPartitioning: number[][];
  27705. facetNb: number;
  27706. partitioningSubdivisions: number;
  27707. partitioningBBoxRatio: number;
  27708. facetDataEnabled: boolean;
  27709. facetParameters: any;
  27710. bbSize: Vector3;
  27711. subDiv: {
  27712. max: number;
  27713. X: number;
  27714. Y: number;
  27715. Z: number;
  27716. };
  27717. facetDepthSort: boolean;
  27718. facetDepthSortEnabled: boolean;
  27719. depthSortedIndices: IndicesArray;
  27720. depthSortedFacets: {
  27721. ind: number;
  27722. sqDistance: number;
  27723. }[];
  27724. facetDepthSortFunction: (f1: {
  27725. ind: number;
  27726. sqDistance: number;
  27727. }, f2: {
  27728. ind: number;
  27729. sqDistance: number;
  27730. }) => number;
  27731. facetDepthSortFrom: Vector3;
  27732. facetDepthSortOrigin: Vector3;
  27733. invertedMatrix: Matrix;
  27734. }
  27735. /**
  27736. * @hidden
  27737. **/
  27738. class _InternalAbstractMeshDataInfo {
  27739. _hasVertexAlpha: boolean;
  27740. _useVertexColors: boolean;
  27741. _numBoneInfluencers: number;
  27742. _applyFog: boolean;
  27743. _receiveShadows: boolean;
  27744. _facetData: _FacetDataStorage;
  27745. _visibility: number;
  27746. _skeleton: Nullable<Skeleton>;
  27747. _layerMask: number;
  27748. _computeBonesUsingShaders: boolean;
  27749. _isActive: boolean;
  27750. _onlyForInstances: boolean;
  27751. _isActiveIntermediate: boolean;
  27752. _onlyForInstancesIntermediate: boolean;
  27753. _actAsRegularMesh: boolean;
  27754. }
  27755. /**
  27756. * Class used to store all common mesh properties
  27757. */
  27758. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27759. /** No occlusion */
  27760. static OCCLUSION_TYPE_NONE: number;
  27761. /** Occlusion set to optimisitic */
  27762. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27763. /** Occlusion set to strict */
  27764. static OCCLUSION_TYPE_STRICT: number;
  27765. /** Use an accurante occlusion algorithm */
  27766. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27767. /** Use a conservative occlusion algorithm */
  27768. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27769. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27770. * Test order :
  27771. * Is the bounding sphere outside the frustum ?
  27772. * If not, are the bounding box vertices outside the frustum ?
  27773. * It not, then the cullable object is in the frustum.
  27774. */
  27775. static readonly CULLINGSTRATEGY_STANDARD: number;
  27776. /** Culling strategy : Bounding Sphere Only.
  27777. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27778. * It's also less accurate than the standard because some not visible objects can still be selected.
  27779. * Test : is the bounding sphere outside the frustum ?
  27780. * If not, then the cullable object is in the frustum.
  27781. */
  27782. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27783. /** Culling strategy : Optimistic Inclusion.
  27784. * This in an inclusion test first, then the standard exclusion test.
  27785. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27786. * 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.
  27787. * Anyway, it's as accurate as the standard strategy.
  27788. * Test :
  27789. * Is the cullable object bounding sphere center in the frustum ?
  27790. * If not, apply the default culling strategy.
  27791. */
  27792. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27793. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27794. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27795. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27796. * 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.
  27797. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27798. * Test :
  27799. * Is the cullable object bounding sphere center in the frustum ?
  27800. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27801. */
  27802. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27803. /**
  27804. * No billboard
  27805. */
  27806. static get BILLBOARDMODE_NONE(): number;
  27807. /** Billboard on X axis */
  27808. static get BILLBOARDMODE_X(): number;
  27809. /** Billboard on Y axis */
  27810. static get BILLBOARDMODE_Y(): number;
  27811. /** Billboard on Z axis */
  27812. static get BILLBOARDMODE_Z(): number;
  27813. /** Billboard on all axes */
  27814. static get BILLBOARDMODE_ALL(): number;
  27815. /** Billboard on using position instead of orientation */
  27816. static get BILLBOARDMODE_USE_POSITION(): number;
  27817. /** @hidden */
  27818. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27819. /**
  27820. * The culling strategy to use to check whether the mesh must be rendered or not.
  27821. * This value can be changed at any time and will be used on the next render mesh selection.
  27822. * The possible values are :
  27823. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27824. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27825. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27826. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27827. * Please read each static variable documentation to get details about the culling process.
  27828. * */
  27829. cullingStrategy: number;
  27830. /**
  27831. * Gets the number of facets in the mesh
  27832. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27833. */
  27834. get facetNb(): number;
  27835. /**
  27836. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27838. */
  27839. get partitioningSubdivisions(): number;
  27840. set partitioningSubdivisions(nb: number);
  27841. /**
  27842. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27843. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27844. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27845. */
  27846. get partitioningBBoxRatio(): number;
  27847. set partitioningBBoxRatio(ratio: number);
  27848. /**
  27849. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27850. * Works only for updatable meshes.
  27851. * Doesn't work with multi-materials
  27852. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27853. */
  27854. get mustDepthSortFacets(): boolean;
  27855. set mustDepthSortFacets(sort: boolean);
  27856. /**
  27857. * The location (Vector3) where the facet depth sort must be computed from.
  27858. * By default, the active camera position.
  27859. * Used only when facet depth sort is enabled
  27860. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27861. */
  27862. get facetDepthSortFrom(): Vector3;
  27863. set facetDepthSortFrom(location: Vector3);
  27864. /**
  27865. * gets a boolean indicating if facetData is enabled
  27866. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27867. */
  27868. get isFacetDataEnabled(): boolean;
  27869. /** @hidden */
  27870. _updateNonUniformScalingState(value: boolean): boolean;
  27871. /**
  27872. * An event triggered when this mesh collides with another one
  27873. */
  27874. onCollideObservable: Observable<AbstractMesh>;
  27875. /** Set a function to call when this mesh collides with another one */
  27876. set onCollide(callback: () => void);
  27877. /**
  27878. * An event triggered when the collision's position changes
  27879. */
  27880. onCollisionPositionChangeObservable: Observable<Vector3>;
  27881. /** Set a function to call when the collision's position changes */
  27882. set onCollisionPositionChange(callback: () => void);
  27883. /**
  27884. * An event triggered when material is changed
  27885. */
  27886. onMaterialChangedObservable: Observable<AbstractMesh>;
  27887. /**
  27888. * Gets or sets the orientation for POV movement & rotation
  27889. */
  27890. definedFacingForward: boolean;
  27891. /** @hidden */
  27892. _occlusionQuery: Nullable<WebGLQuery>;
  27893. /** @hidden */
  27894. _renderingGroup: Nullable<RenderingGroup>;
  27895. /**
  27896. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27897. */
  27898. get visibility(): number;
  27899. /**
  27900. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27901. */
  27902. set visibility(value: number);
  27903. /** Gets or sets the alpha index used to sort transparent meshes
  27904. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27905. */
  27906. alphaIndex: number;
  27907. /**
  27908. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27909. */
  27910. isVisible: boolean;
  27911. /**
  27912. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27913. */
  27914. isPickable: boolean;
  27915. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27916. showSubMeshesBoundingBox: boolean;
  27917. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27919. */
  27920. isBlocker: boolean;
  27921. /**
  27922. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27923. */
  27924. enablePointerMoveEvents: boolean;
  27925. /**
  27926. * Specifies the rendering group id for this mesh (0 by default)
  27927. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27928. */
  27929. renderingGroupId: number;
  27930. private _material;
  27931. /** Gets or sets current material */
  27932. get material(): Nullable<Material>;
  27933. set material(value: Nullable<Material>);
  27934. /**
  27935. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27936. * @see http://doc.babylonjs.com/babylon101/shadows
  27937. */
  27938. get receiveShadows(): boolean;
  27939. set receiveShadows(value: boolean);
  27940. /** Defines color to use when rendering outline */
  27941. outlineColor: Color3;
  27942. /** Define width to use when rendering outline */
  27943. outlineWidth: number;
  27944. /** Defines color to use when rendering overlay */
  27945. overlayColor: Color3;
  27946. /** Defines alpha to use when rendering overlay */
  27947. overlayAlpha: number;
  27948. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27949. get hasVertexAlpha(): boolean;
  27950. set hasVertexAlpha(value: boolean);
  27951. /** 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) */
  27952. get useVertexColors(): boolean;
  27953. set useVertexColors(value: boolean);
  27954. /**
  27955. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27956. */
  27957. get computeBonesUsingShaders(): boolean;
  27958. set computeBonesUsingShaders(value: boolean);
  27959. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27960. get numBoneInfluencers(): number;
  27961. set numBoneInfluencers(value: number);
  27962. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27963. get applyFog(): boolean;
  27964. set applyFog(value: boolean);
  27965. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27966. useOctreeForRenderingSelection: boolean;
  27967. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27968. useOctreeForPicking: boolean;
  27969. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27970. useOctreeForCollisions: boolean;
  27971. /**
  27972. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27973. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27974. */
  27975. get layerMask(): number;
  27976. set layerMask(value: number);
  27977. /**
  27978. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27979. */
  27980. alwaysSelectAsActiveMesh: boolean;
  27981. /**
  27982. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27983. */
  27984. doNotSyncBoundingInfo: boolean;
  27985. /**
  27986. * Gets or sets the current action manager
  27987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27988. */
  27989. actionManager: Nullable<AbstractActionManager>;
  27990. private _meshCollisionData;
  27991. /**
  27992. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27993. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27994. */
  27995. ellipsoid: Vector3;
  27996. /**
  27997. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27998. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27999. */
  28000. ellipsoidOffset: Vector3;
  28001. /**
  28002. * Gets or sets a collision mask used to mask collisions (default is -1).
  28003. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28004. */
  28005. get collisionMask(): number;
  28006. set collisionMask(mask: number);
  28007. /**
  28008. * Gets or sets the current collision group mask (-1 by default).
  28009. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28010. */
  28011. get collisionGroup(): number;
  28012. set collisionGroup(mask: number);
  28013. /**
  28014. * Defines edge width used when edgesRenderer is enabled
  28015. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28016. */
  28017. edgesWidth: number;
  28018. /**
  28019. * Defines edge color used when edgesRenderer is enabled
  28020. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28021. */
  28022. edgesColor: Color4;
  28023. /** @hidden */
  28024. _edgesRenderer: Nullable<IEdgesRenderer>;
  28025. /** @hidden */
  28026. _masterMesh: Nullable<AbstractMesh>;
  28027. /** @hidden */
  28028. _boundingInfo: Nullable<BoundingInfo>;
  28029. /** @hidden */
  28030. _renderId: number;
  28031. /**
  28032. * Gets or sets the list of subMeshes
  28033. * @see http://doc.babylonjs.com/how_to/multi_materials
  28034. */
  28035. subMeshes: SubMesh[];
  28036. /** @hidden */
  28037. _intersectionsInProgress: AbstractMesh[];
  28038. /** @hidden */
  28039. _unIndexed: boolean;
  28040. /** @hidden */
  28041. _lightSources: Light[];
  28042. /** Gets the list of lights affecting that mesh */
  28043. get lightSources(): Light[];
  28044. /** @hidden */
  28045. get _positions(): Nullable<Vector3[]>;
  28046. /** @hidden */
  28047. _waitingData: {
  28048. lods: Nullable<any>;
  28049. actions: Nullable<any>;
  28050. freezeWorldMatrix: Nullable<boolean>;
  28051. };
  28052. /** @hidden */
  28053. _bonesTransformMatrices: Nullable<Float32Array>;
  28054. /** @hidden */
  28055. _transformMatrixTexture: Nullable<RawTexture>;
  28056. /**
  28057. * Gets or sets a skeleton to apply skining transformations
  28058. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28059. */
  28060. set skeleton(value: Nullable<Skeleton>);
  28061. get skeleton(): Nullable<Skeleton>;
  28062. /**
  28063. * An event triggered when the mesh is rebuilt.
  28064. */
  28065. onRebuildObservable: Observable<AbstractMesh>;
  28066. /**
  28067. * Creates a new AbstractMesh
  28068. * @param name defines the name of the mesh
  28069. * @param scene defines the hosting scene
  28070. */
  28071. constructor(name: string, scene?: Nullable<Scene>);
  28072. /**
  28073. * Returns the string "AbstractMesh"
  28074. * @returns "AbstractMesh"
  28075. */
  28076. getClassName(): string;
  28077. /**
  28078. * Gets a string representation of the current mesh
  28079. * @param fullDetails defines a boolean indicating if full details must be included
  28080. * @returns a string representation of the current mesh
  28081. */
  28082. toString(fullDetails?: boolean): string;
  28083. /**
  28084. * @hidden
  28085. */
  28086. protected _getEffectiveParent(): Nullable<Node>;
  28087. /** @hidden */
  28088. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28089. /** @hidden */
  28090. _rebuild(): void;
  28091. /** @hidden */
  28092. _resyncLightSources(): void;
  28093. /** @hidden */
  28094. _resyncLightSource(light: Light): void;
  28095. /** @hidden */
  28096. _unBindEffect(): void;
  28097. /** @hidden */
  28098. _removeLightSource(light: Light, dispose: boolean): void;
  28099. private _markSubMeshesAsDirty;
  28100. /** @hidden */
  28101. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28102. /** @hidden */
  28103. _markSubMeshesAsAttributesDirty(): void;
  28104. /** @hidden */
  28105. _markSubMeshesAsMiscDirty(): void;
  28106. /**
  28107. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28108. */
  28109. get scaling(): Vector3;
  28110. set scaling(newScaling: Vector3);
  28111. /**
  28112. * Returns true if the mesh is blocked. Implemented by child classes
  28113. */
  28114. get isBlocked(): boolean;
  28115. /**
  28116. * Returns the mesh itself by default. Implemented by child classes
  28117. * @param camera defines the camera to use to pick the right LOD level
  28118. * @returns the currentAbstractMesh
  28119. */
  28120. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28121. /**
  28122. * Returns 0 by default. Implemented by child classes
  28123. * @returns an integer
  28124. */
  28125. getTotalVertices(): number;
  28126. /**
  28127. * Returns a positive integer : the total number of indices in this mesh geometry.
  28128. * @returns the numner of indices or zero if the mesh has no geometry.
  28129. */
  28130. getTotalIndices(): number;
  28131. /**
  28132. * Returns null by default. Implemented by child classes
  28133. * @returns null
  28134. */
  28135. getIndices(): Nullable<IndicesArray>;
  28136. /**
  28137. * Returns the array of the requested vertex data kind. Implemented by child classes
  28138. * @param kind defines the vertex data kind to use
  28139. * @returns null
  28140. */
  28141. getVerticesData(kind: string): Nullable<FloatArray>;
  28142. /**
  28143. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28144. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28145. * Note that a new underlying VertexBuffer object is created each call.
  28146. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28147. * @param kind defines vertex data kind:
  28148. * * VertexBuffer.PositionKind
  28149. * * VertexBuffer.UVKind
  28150. * * VertexBuffer.UV2Kind
  28151. * * VertexBuffer.UV3Kind
  28152. * * VertexBuffer.UV4Kind
  28153. * * VertexBuffer.UV5Kind
  28154. * * VertexBuffer.UV6Kind
  28155. * * VertexBuffer.ColorKind
  28156. * * VertexBuffer.MatricesIndicesKind
  28157. * * VertexBuffer.MatricesIndicesExtraKind
  28158. * * VertexBuffer.MatricesWeightsKind
  28159. * * VertexBuffer.MatricesWeightsExtraKind
  28160. * @param data defines the data source
  28161. * @param updatable defines if the data must be flagged as updatable (or static)
  28162. * @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
  28163. * @returns the current mesh
  28164. */
  28165. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28166. /**
  28167. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28168. * If the mesh has no geometry, it is simply returned as it is.
  28169. * @param kind defines vertex data kind:
  28170. * * VertexBuffer.PositionKind
  28171. * * VertexBuffer.UVKind
  28172. * * VertexBuffer.UV2Kind
  28173. * * VertexBuffer.UV3Kind
  28174. * * VertexBuffer.UV4Kind
  28175. * * VertexBuffer.UV5Kind
  28176. * * VertexBuffer.UV6Kind
  28177. * * VertexBuffer.ColorKind
  28178. * * VertexBuffer.MatricesIndicesKind
  28179. * * VertexBuffer.MatricesIndicesExtraKind
  28180. * * VertexBuffer.MatricesWeightsKind
  28181. * * VertexBuffer.MatricesWeightsExtraKind
  28182. * @param data defines the data source
  28183. * @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
  28184. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28185. * @returns the current mesh
  28186. */
  28187. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28188. /**
  28189. * Sets the mesh indices,
  28190. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28191. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28192. * @param totalVertices Defines the total number of vertices
  28193. * @returns the current mesh
  28194. */
  28195. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28196. /**
  28197. * Gets a boolean indicating if specific vertex data is present
  28198. * @param kind defines the vertex data kind to use
  28199. * @returns true is data kind is present
  28200. */
  28201. isVerticesDataPresent(kind: string): boolean;
  28202. /**
  28203. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28204. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28205. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28206. * @returns a BoundingInfo
  28207. */
  28208. getBoundingInfo(): BoundingInfo;
  28209. /**
  28210. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28211. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28212. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28213. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28214. * @returns the current mesh
  28215. */
  28216. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28217. /**
  28218. * Overwrite the current bounding info
  28219. * @param boundingInfo defines the new bounding info
  28220. * @returns the current mesh
  28221. */
  28222. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28223. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28224. get useBones(): boolean;
  28225. /** @hidden */
  28226. _preActivate(): void;
  28227. /** @hidden */
  28228. _preActivateForIntermediateRendering(renderId: number): void;
  28229. /** @hidden */
  28230. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28231. /** @hidden */
  28232. _postActivate(): void;
  28233. /** @hidden */
  28234. _freeze(): void;
  28235. /** @hidden */
  28236. _unFreeze(): void;
  28237. /**
  28238. * Gets the current world matrix
  28239. * @returns a Matrix
  28240. */
  28241. getWorldMatrix(): Matrix;
  28242. /** @hidden */
  28243. _getWorldMatrixDeterminant(): number;
  28244. /**
  28245. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28246. */
  28247. get isAnInstance(): boolean;
  28248. /**
  28249. * Gets a boolean indicating if this mesh has instances
  28250. */
  28251. get hasInstances(): boolean;
  28252. /**
  28253. * Perform relative position change from the point of view of behind the front of the mesh.
  28254. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28255. * Supports definition of mesh facing forward or backward
  28256. * @param amountRight defines the distance on the right axis
  28257. * @param amountUp defines the distance on the up axis
  28258. * @param amountForward defines the distance on the forward axis
  28259. * @returns the current mesh
  28260. */
  28261. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28262. /**
  28263. * Calculate relative position change from the point of view of behind the front of the mesh.
  28264. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28265. * Supports definition of mesh facing forward or backward
  28266. * @param amountRight defines the distance on the right axis
  28267. * @param amountUp defines the distance on the up axis
  28268. * @param amountForward defines the distance on the forward axis
  28269. * @returns the new displacement vector
  28270. */
  28271. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28272. /**
  28273. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28274. * Supports definition of mesh facing forward or backward
  28275. * @param flipBack defines the flip
  28276. * @param twirlClockwise defines the twirl
  28277. * @param tiltRight defines the tilt
  28278. * @returns the current mesh
  28279. */
  28280. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28281. /**
  28282. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28283. * Supports definition of mesh facing forward or backward.
  28284. * @param flipBack defines the flip
  28285. * @param twirlClockwise defines the twirl
  28286. * @param tiltRight defines the tilt
  28287. * @returns the new rotation vector
  28288. */
  28289. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28290. /**
  28291. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28292. * This means the mesh underlying bounding box and sphere are recomputed.
  28293. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28294. * @returns the current mesh
  28295. */
  28296. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28297. /** @hidden */
  28298. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28299. /** @hidden */
  28300. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28301. /** @hidden */
  28302. _updateBoundingInfo(): AbstractMesh;
  28303. /** @hidden */
  28304. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28305. /** @hidden */
  28306. protected _afterComputeWorldMatrix(): void;
  28307. /** @hidden */
  28308. get _effectiveMesh(): AbstractMesh;
  28309. /**
  28310. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28311. * A mesh is in the frustum if its bounding box intersects the frustum
  28312. * @param frustumPlanes defines the frustum to test
  28313. * @returns true if the mesh is in the frustum planes
  28314. */
  28315. isInFrustum(frustumPlanes: Plane[]): boolean;
  28316. /**
  28317. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28318. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28319. * @param frustumPlanes defines the frustum to test
  28320. * @returns true if the mesh is completely in the frustum planes
  28321. */
  28322. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28323. /**
  28324. * True if the mesh intersects another mesh or a SolidParticle object
  28325. * @param mesh defines a target mesh or SolidParticle to test
  28326. * @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)
  28327. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28328. * @returns true if there is an intersection
  28329. */
  28330. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28331. /**
  28332. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28333. * @param point defines the point to test
  28334. * @returns true if there is an intersection
  28335. */
  28336. intersectsPoint(point: Vector3): boolean;
  28337. /**
  28338. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28339. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28340. */
  28341. get checkCollisions(): boolean;
  28342. set checkCollisions(collisionEnabled: boolean);
  28343. /**
  28344. * Gets Collider object used to compute collisions (not physics)
  28345. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28346. */
  28347. get collider(): Nullable<Collider>;
  28348. /**
  28349. * Move the mesh using collision engine
  28350. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28351. * @param displacement defines the requested displacement vector
  28352. * @returns the current mesh
  28353. */
  28354. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28355. private _onCollisionPositionChange;
  28356. /** @hidden */
  28357. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28358. /** @hidden */
  28359. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28360. /** @hidden */
  28361. _checkCollision(collider: Collider): AbstractMesh;
  28362. /** @hidden */
  28363. _generatePointsArray(): boolean;
  28364. /**
  28365. * Checks if the passed Ray intersects with the mesh
  28366. * @param ray defines the ray to use
  28367. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28368. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28369. * @returns the picking info
  28370. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28371. */
  28372. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28373. /**
  28374. * Clones the current mesh
  28375. * @param name defines the mesh name
  28376. * @param newParent defines the new mesh parent
  28377. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28378. * @returns the new mesh
  28379. */
  28380. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28381. /**
  28382. * Disposes all the submeshes of the current meshnp
  28383. * @returns the current mesh
  28384. */
  28385. releaseSubMeshes(): AbstractMesh;
  28386. /**
  28387. * Releases resources associated with this abstract mesh.
  28388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28390. */
  28391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28392. /**
  28393. * Adds the passed mesh as a child to the current mesh
  28394. * @param mesh defines the child mesh
  28395. * @returns the current mesh
  28396. */
  28397. addChild(mesh: AbstractMesh): AbstractMesh;
  28398. /**
  28399. * Removes the passed mesh from the current mesh children list
  28400. * @param mesh defines the child mesh
  28401. * @returns the current mesh
  28402. */
  28403. removeChild(mesh: AbstractMesh): AbstractMesh;
  28404. /** @hidden */
  28405. private _initFacetData;
  28406. /**
  28407. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28408. * This method can be called within the render loop.
  28409. * 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
  28410. * @returns the current mesh
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28412. */
  28413. updateFacetData(): AbstractMesh;
  28414. /**
  28415. * Returns the facetLocalNormals array.
  28416. * The normals are expressed in the mesh local spac
  28417. * @returns an array of Vector3
  28418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28419. */
  28420. getFacetLocalNormals(): Vector3[];
  28421. /**
  28422. * Returns the facetLocalPositions array.
  28423. * The facet positions are expressed in the mesh local space
  28424. * @returns an array of Vector3
  28425. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28426. */
  28427. getFacetLocalPositions(): Vector3[];
  28428. /**
  28429. * Returns the facetLocalPartioning array
  28430. * @returns an array of array of numbers
  28431. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28432. */
  28433. getFacetLocalPartitioning(): number[][];
  28434. /**
  28435. * Returns the i-th facet position in the world system.
  28436. * This method allocates a new Vector3 per call
  28437. * @param i defines the facet index
  28438. * @returns a new Vector3
  28439. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28440. */
  28441. getFacetPosition(i: number): Vector3;
  28442. /**
  28443. * Sets the reference Vector3 with the i-th facet position in the world system
  28444. * @param i defines the facet index
  28445. * @param ref defines the target vector
  28446. * @returns the current mesh
  28447. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28448. */
  28449. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28450. /**
  28451. * Returns the i-th facet normal in the world system.
  28452. * This method allocates a new Vector3 per call
  28453. * @param i defines the facet index
  28454. * @returns a new Vector3
  28455. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28456. */
  28457. getFacetNormal(i: number): Vector3;
  28458. /**
  28459. * Sets the reference Vector3 with the i-th facet normal in the world system
  28460. * @param i defines the facet index
  28461. * @param ref defines the target vector
  28462. * @returns the current mesh
  28463. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28464. */
  28465. getFacetNormalToRef(i: number, ref: Vector3): this;
  28466. /**
  28467. * 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)
  28468. * @param x defines x coordinate
  28469. * @param y defines y coordinate
  28470. * @param z defines z coordinate
  28471. * @returns the array of facet indexes
  28472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28473. */
  28474. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28475. /**
  28476. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28477. * @param projected sets as the (x,y,z) world projection on the facet
  28478. * @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
  28479. * @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
  28480. * @param x defines x coordinate
  28481. * @param y defines y coordinate
  28482. * @param z defines z coordinate
  28483. * @returns the face index if found (or null instead)
  28484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28485. */
  28486. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28487. /**
  28488. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28489. * @param projected sets as the (x,y,z) local projection on the facet
  28490. * @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
  28491. * @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
  28492. * @param x defines x coordinate
  28493. * @param y defines y coordinate
  28494. * @param z defines z coordinate
  28495. * @returns the face index if found (or null instead)
  28496. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28497. */
  28498. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28499. /**
  28500. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28501. * @returns the parameters
  28502. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28503. */
  28504. getFacetDataParameters(): any;
  28505. /**
  28506. * Disables the feature FacetData and frees the related memory
  28507. * @returns the current mesh
  28508. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28509. */
  28510. disableFacetData(): AbstractMesh;
  28511. /**
  28512. * Updates the AbstractMesh indices array
  28513. * @param indices defines the data source
  28514. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28515. * @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)
  28516. * @returns the current mesh
  28517. */
  28518. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28519. /**
  28520. * Creates new normals data for the mesh
  28521. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28522. * @returns the current mesh
  28523. */
  28524. createNormals(updatable: boolean): AbstractMesh;
  28525. /**
  28526. * Align the mesh with a normal
  28527. * @param normal defines the normal to use
  28528. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28529. * @returns the current mesh
  28530. */
  28531. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28532. /** @hidden */
  28533. _checkOcclusionQuery(): boolean;
  28534. /**
  28535. * Disables the mesh edge rendering mode
  28536. * @returns the currentAbstractMesh
  28537. */
  28538. disableEdgesRendering(): AbstractMesh;
  28539. /**
  28540. * Enables the edge rendering mode on the mesh.
  28541. * This mode makes the mesh edges visible
  28542. * @param epsilon defines the maximal distance between two angles to detect a face
  28543. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28544. * @returns the currentAbstractMesh
  28545. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28546. */
  28547. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28548. }
  28549. }
  28550. declare module BABYLON {
  28551. /**
  28552. * Interface used to define ActionEvent
  28553. */
  28554. export interface IActionEvent {
  28555. /** The mesh or sprite that triggered the action */
  28556. source: any;
  28557. /** The X mouse cursor position at the time of the event */
  28558. pointerX: number;
  28559. /** The Y mouse cursor position at the time of the event */
  28560. pointerY: number;
  28561. /** The mesh that is currently pointed at (can be null) */
  28562. meshUnderPointer: Nullable<AbstractMesh>;
  28563. /** the original (browser) event that triggered the ActionEvent */
  28564. sourceEvent?: any;
  28565. /** additional data for the event */
  28566. additionalData?: any;
  28567. }
  28568. /**
  28569. * ActionEvent is the event being sent when an action is triggered.
  28570. */
  28571. export class ActionEvent implements IActionEvent {
  28572. /** The mesh or sprite that triggered the action */
  28573. source: any;
  28574. /** The X mouse cursor position at the time of the event */
  28575. pointerX: number;
  28576. /** The Y mouse cursor position at the time of the event */
  28577. pointerY: number;
  28578. /** The mesh that is currently pointed at (can be null) */
  28579. meshUnderPointer: Nullable<AbstractMesh>;
  28580. /** the original (browser) event that triggered the ActionEvent */
  28581. sourceEvent?: any;
  28582. /** additional data for the event */
  28583. additionalData?: any;
  28584. /**
  28585. * Creates a new ActionEvent
  28586. * @param source The mesh or sprite that triggered the action
  28587. * @param pointerX The X mouse cursor position at the time of the event
  28588. * @param pointerY The Y mouse cursor position at the time of the event
  28589. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28590. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28591. * @param additionalData additional data for the event
  28592. */
  28593. constructor(
  28594. /** The mesh or sprite that triggered the action */
  28595. source: any,
  28596. /** The X mouse cursor position at the time of the event */
  28597. pointerX: number,
  28598. /** The Y mouse cursor position at the time of the event */
  28599. pointerY: number,
  28600. /** The mesh that is currently pointed at (can be null) */
  28601. meshUnderPointer: Nullable<AbstractMesh>,
  28602. /** the original (browser) event that triggered the ActionEvent */
  28603. sourceEvent?: any,
  28604. /** additional data for the event */
  28605. additionalData?: any);
  28606. /**
  28607. * Helper function to auto-create an ActionEvent from a source mesh.
  28608. * @param source The source mesh that triggered the event
  28609. * @param evt The original (browser) event
  28610. * @param additionalData additional data for the event
  28611. * @returns the new ActionEvent
  28612. */
  28613. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28614. /**
  28615. * Helper function to auto-create an ActionEvent from a source sprite
  28616. * @param source The source sprite that triggered the event
  28617. * @param scene Scene associated with the sprite
  28618. * @param evt The original (browser) event
  28619. * @param additionalData additional data for the event
  28620. * @returns the new ActionEvent
  28621. */
  28622. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28623. /**
  28624. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28625. * @param scene the scene where the event occurred
  28626. * @param evt The original (browser) event
  28627. * @returns the new ActionEvent
  28628. */
  28629. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28630. /**
  28631. * Helper function to auto-create an ActionEvent from a primitive
  28632. * @param prim defines the target primitive
  28633. * @param pointerPos defines the pointer position
  28634. * @param evt The original (browser) event
  28635. * @param additionalData additional data for the event
  28636. * @returns the new ActionEvent
  28637. */
  28638. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28639. }
  28640. }
  28641. declare module BABYLON {
  28642. /**
  28643. * Abstract class used to decouple action Manager from scene and meshes.
  28644. * Do not instantiate.
  28645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28646. */
  28647. export abstract class AbstractActionManager implements IDisposable {
  28648. /** Gets the list of active triggers */
  28649. static Triggers: {
  28650. [key: string]: number;
  28651. };
  28652. /** Gets the cursor to use when hovering items */
  28653. hoverCursor: string;
  28654. /** Gets the list of actions */
  28655. actions: IAction[];
  28656. /**
  28657. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28658. */
  28659. isRecursive: boolean;
  28660. /**
  28661. * Releases all associated resources
  28662. */
  28663. abstract dispose(): void;
  28664. /**
  28665. * Does this action manager has pointer triggers
  28666. */
  28667. abstract get hasPointerTriggers(): boolean;
  28668. /**
  28669. * Does this action manager has pick triggers
  28670. */
  28671. abstract get hasPickTriggers(): boolean;
  28672. /**
  28673. * Process a specific trigger
  28674. * @param trigger defines the trigger to process
  28675. * @param evt defines the event details to be processed
  28676. */
  28677. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28678. /**
  28679. * Does this action manager handles actions of any of the given triggers
  28680. * @param triggers defines the triggers to be tested
  28681. * @return a boolean indicating whether one (or more) of the triggers is handled
  28682. */
  28683. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28684. /**
  28685. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28686. * speed.
  28687. * @param triggerA defines the trigger to be tested
  28688. * @param triggerB defines the trigger to be tested
  28689. * @return a boolean indicating whether one (or more) of the triggers is handled
  28690. */
  28691. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28692. /**
  28693. * Does this action manager handles actions of a given trigger
  28694. * @param trigger defines the trigger to be tested
  28695. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28696. * @return whether the trigger is handled
  28697. */
  28698. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28699. /**
  28700. * Serialize this manager to a JSON object
  28701. * @param name defines the property name to store this manager
  28702. * @returns a JSON representation of this manager
  28703. */
  28704. abstract serialize(name: string): any;
  28705. /**
  28706. * Registers an action to this action manager
  28707. * @param action defines the action to be registered
  28708. * @return the action amended (prepared) after registration
  28709. */
  28710. abstract registerAction(action: IAction): Nullable<IAction>;
  28711. /**
  28712. * Unregisters an action to this action manager
  28713. * @param action defines the action to be unregistered
  28714. * @return a boolean indicating whether the action has been unregistered
  28715. */
  28716. abstract unregisterAction(action: IAction): Boolean;
  28717. /**
  28718. * Does exist one action manager with at least one trigger
  28719. **/
  28720. static get HasTriggers(): boolean;
  28721. /**
  28722. * Does exist one action manager with at least one pick trigger
  28723. **/
  28724. static get HasPickTriggers(): boolean;
  28725. /**
  28726. * Does exist one action manager that handles actions of a given trigger
  28727. * @param trigger defines the trigger to be tested
  28728. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28729. **/
  28730. static HasSpecificTrigger(trigger: number): boolean;
  28731. }
  28732. }
  28733. declare module BABYLON {
  28734. /**
  28735. * Defines how a node can be built from a string name.
  28736. */
  28737. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28738. /**
  28739. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28740. */
  28741. export class Node implements IBehaviorAware<Node> {
  28742. /** @hidden */
  28743. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28744. private static _NodeConstructors;
  28745. /**
  28746. * Add a new node constructor
  28747. * @param type defines the type name of the node to construct
  28748. * @param constructorFunc defines the constructor function
  28749. */
  28750. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28751. /**
  28752. * Returns a node constructor based on type name
  28753. * @param type defines the type name
  28754. * @param name defines the new node name
  28755. * @param scene defines the hosting scene
  28756. * @param options defines optional options to transmit to constructors
  28757. * @returns the new constructor or null
  28758. */
  28759. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28760. /**
  28761. * Gets or sets the name of the node
  28762. */
  28763. name: string;
  28764. /**
  28765. * Gets or sets the id of the node
  28766. */
  28767. id: string;
  28768. /**
  28769. * Gets or sets the unique id of the node
  28770. */
  28771. uniqueId: number;
  28772. /**
  28773. * Gets or sets a string used to store user defined state for the node
  28774. */
  28775. state: string;
  28776. /**
  28777. * Gets or sets an object used to store user defined information for the node
  28778. */
  28779. metadata: any;
  28780. /**
  28781. * For internal use only. Please do not use.
  28782. */
  28783. reservedDataStore: any;
  28784. /**
  28785. * List of inspectable custom properties (used by the Inspector)
  28786. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28787. */
  28788. inspectableCustomProperties: IInspectable[];
  28789. private _doNotSerialize;
  28790. /**
  28791. * Gets or sets a boolean used to define if the node must be serialized
  28792. */
  28793. get doNotSerialize(): boolean;
  28794. set doNotSerialize(value: boolean);
  28795. /** @hidden */
  28796. _isDisposed: boolean;
  28797. /**
  28798. * Gets a list of Animations associated with the node
  28799. */
  28800. animations: Animation[];
  28801. protected _ranges: {
  28802. [name: string]: Nullable<AnimationRange>;
  28803. };
  28804. /**
  28805. * Callback raised when the node is ready to be used
  28806. */
  28807. onReady: Nullable<(node: Node) => void>;
  28808. private _isEnabled;
  28809. private _isParentEnabled;
  28810. private _isReady;
  28811. /** @hidden */
  28812. _currentRenderId: number;
  28813. private _parentUpdateId;
  28814. /** @hidden */
  28815. _childUpdateId: number;
  28816. /** @hidden */
  28817. _waitingParentId: Nullable<string>;
  28818. /** @hidden */
  28819. _scene: Scene;
  28820. /** @hidden */
  28821. _cache: any;
  28822. private _parentNode;
  28823. private _children;
  28824. /** @hidden */
  28825. _worldMatrix: Matrix;
  28826. /** @hidden */
  28827. _worldMatrixDeterminant: number;
  28828. /** @hidden */
  28829. _worldMatrixDeterminantIsDirty: boolean;
  28830. /** @hidden */
  28831. private _sceneRootNodesIndex;
  28832. /**
  28833. * Gets a boolean indicating if the node has been disposed
  28834. * @returns true if the node was disposed
  28835. */
  28836. isDisposed(): boolean;
  28837. /**
  28838. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28839. * @see https://doc.babylonjs.com/how_to/parenting
  28840. */
  28841. set parent(parent: Nullable<Node>);
  28842. get parent(): Nullable<Node>;
  28843. /** @hidden */
  28844. _addToSceneRootNodes(): void;
  28845. /** @hidden */
  28846. _removeFromSceneRootNodes(): void;
  28847. private _animationPropertiesOverride;
  28848. /**
  28849. * Gets or sets the animation properties override
  28850. */
  28851. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28852. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28853. /**
  28854. * Gets a string idenfifying the name of the class
  28855. * @returns "Node" string
  28856. */
  28857. getClassName(): string;
  28858. /** @hidden */
  28859. readonly _isNode: boolean;
  28860. /**
  28861. * An event triggered when the mesh is disposed
  28862. */
  28863. onDisposeObservable: Observable<Node>;
  28864. private _onDisposeObserver;
  28865. /**
  28866. * Sets a callback that will be raised when the node will be disposed
  28867. */
  28868. set onDispose(callback: () => void);
  28869. /**
  28870. * Creates a new Node
  28871. * @param name the name and id to be given to this node
  28872. * @param scene the scene this node will be added to
  28873. */
  28874. constructor(name: string, scene?: Nullable<Scene>);
  28875. /**
  28876. * Gets the scene of the node
  28877. * @returns a scene
  28878. */
  28879. getScene(): Scene;
  28880. /**
  28881. * Gets the engine of the node
  28882. * @returns a Engine
  28883. */
  28884. getEngine(): Engine;
  28885. private _behaviors;
  28886. /**
  28887. * Attach a behavior to the node
  28888. * @see http://doc.babylonjs.com/features/behaviour
  28889. * @param behavior defines the behavior to attach
  28890. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28891. * @returns the current Node
  28892. */
  28893. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28894. /**
  28895. * Remove an attached behavior
  28896. * @see http://doc.babylonjs.com/features/behaviour
  28897. * @param behavior defines the behavior to attach
  28898. * @returns the current Node
  28899. */
  28900. removeBehavior(behavior: Behavior<Node>): Node;
  28901. /**
  28902. * Gets the list of attached behaviors
  28903. * @see http://doc.babylonjs.com/features/behaviour
  28904. */
  28905. get behaviors(): Behavior<Node>[];
  28906. /**
  28907. * Gets an attached behavior by name
  28908. * @param name defines the name of the behavior to look for
  28909. * @see http://doc.babylonjs.com/features/behaviour
  28910. * @returns null if behavior was not found else the requested behavior
  28911. */
  28912. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28913. /**
  28914. * Returns the latest update of the World matrix
  28915. * @returns a Matrix
  28916. */
  28917. getWorldMatrix(): Matrix;
  28918. /** @hidden */
  28919. _getWorldMatrixDeterminant(): number;
  28920. /**
  28921. * Returns directly the latest state of the mesh World matrix.
  28922. * A Matrix is returned.
  28923. */
  28924. get worldMatrixFromCache(): Matrix;
  28925. /** @hidden */
  28926. _initCache(): void;
  28927. /** @hidden */
  28928. updateCache(force?: boolean): void;
  28929. /** @hidden */
  28930. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28931. /** @hidden */
  28932. _updateCache(ignoreParentClass?: boolean): void;
  28933. /** @hidden */
  28934. _isSynchronized(): boolean;
  28935. /** @hidden */
  28936. _markSyncedWithParent(): void;
  28937. /** @hidden */
  28938. isSynchronizedWithParent(): boolean;
  28939. /** @hidden */
  28940. isSynchronized(): boolean;
  28941. /**
  28942. * Is this node ready to be used/rendered
  28943. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28944. * @return true if the node is ready
  28945. */
  28946. isReady(completeCheck?: boolean): boolean;
  28947. /**
  28948. * Is this node enabled?
  28949. * 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
  28950. * @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
  28951. * @return whether this node (and its parent) is enabled
  28952. */
  28953. isEnabled(checkAncestors?: boolean): boolean;
  28954. /** @hidden */
  28955. protected _syncParentEnabledState(): void;
  28956. /**
  28957. * Set the enabled state of this node
  28958. * @param value defines the new enabled state
  28959. */
  28960. setEnabled(value: boolean): void;
  28961. /**
  28962. * Is this node a descendant of the given node?
  28963. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28964. * @param ancestor defines the parent node to inspect
  28965. * @returns a boolean indicating if this node is a descendant of the given node
  28966. */
  28967. isDescendantOf(ancestor: Node): boolean;
  28968. /** @hidden */
  28969. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28970. /**
  28971. * Will return all nodes that have this node as ascendant
  28972. * @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
  28973. * @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
  28974. * @return all children nodes of all types
  28975. */
  28976. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28977. /**
  28978. * Get all child-meshes of this node
  28979. * @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)
  28980. * @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
  28981. * @returns an array of AbstractMesh
  28982. */
  28983. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28984. /**
  28985. * Get all direct children of this node
  28986. * @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
  28987. * @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)
  28988. * @returns an array of Node
  28989. */
  28990. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28991. /** @hidden */
  28992. _setReady(state: boolean): void;
  28993. /**
  28994. * Get an animation by name
  28995. * @param name defines the name of the animation to look for
  28996. * @returns null if not found else the requested animation
  28997. */
  28998. getAnimationByName(name: string): Nullable<Animation>;
  28999. /**
  29000. * Creates an animation range for this node
  29001. * @param name defines the name of the range
  29002. * @param from defines the starting key
  29003. * @param to defines the end key
  29004. */
  29005. createAnimationRange(name: string, from: number, to: number): void;
  29006. /**
  29007. * Delete a specific animation range
  29008. * @param name defines the name of the range to delete
  29009. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29010. */
  29011. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29012. /**
  29013. * Get an animation range by name
  29014. * @param name defines the name of the animation range to look for
  29015. * @returns null if not found else the requested animation range
  29016. */
  29017. getAnimationRange(name: string): Nullable<AnimationRange>;
  29018. /**
  29019. * Gets the list of all animation ranges defined on this node
  29020. * @returns an array
  29021. */
  29022. getAnimationRanges(): Nullable<AnimationRange>[];
  29023. /**
  29024. * Will start the animation sequence
  29025. * @param name defines the range frames for animation sequence
  29026. * @param loop defines if the animation should loop (false by default)
  29027. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29028. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29029. * @returns the object created for this animation. If range does not exist, it will return null
  29030. */
  29031. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29032. /**
  29033. * Serialize animation ranges into a JSON compatible object
  29034. * @returns serialization object
  29035. */
  29036. serializeAnimationRanges(): any;
  29037. /**
  29038. * Computes the world matrix of the node
  29039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29040. * @returns the world matrix
  29041. */
  29042. computeWorldMatrix(force?: boolean): Matrix;
  29043. /**
  29044. * Releases resources associated with this node.
  29045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29047. */
  29048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29049. /**
  29050. * Parse animation range data from a serialization object and store them into a given node
  29051. * @param node defines where to store the animation ranges
  29052. * @param parsedNode defines the serialization object to read data from
  29053. * @param scene defines the hosting scene
  29054. */
  29055. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29056. /**
  29057. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29058. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29059. * @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
  29060. * @returns the new bounding vectors
  29061. */
  29062. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29063. min: Vector3;
  29064. max: Vector3;
  29065. };
  29066. }
  29067. }
  29068. declare module BABYLON {
  29069. /**
  29070. * @hidden
  29071. */
  29072. export class _IAnimationState {
  29073. key: number;
  29074. repeatCount: number;
  29075. workValue?: any;
  29076. loopMode?: number;
  29077. offsetValue?: any;
  29078. highLimitValue?: any;
  29079. }
  29080. /**
  29081. * Class used to store any kind of animation
  29082. */
  29083. export class Animation {
  29084. /**Name of the animation */
  29085. name: string;
  29086. /**Property to animate */
  29087. targetProperty: string;
  29088. /**The frames per second of the animation */
  29089. framePerSecond: number;
  29090. /**The data type of the animation */
  29091. dataType: number;
  29092. /**The loop mode of the animation */
  29093. loopMode?: number | undefined;
  29094. /**Specifies if blending should be enabled */
  29095. enableBlending?: boolean | undefined;
  29096. /**
  29097. * Use matrix interpolation instead of using direct key value when animating matrices
  29098. */
  29099. static AllowMatricesInterpolation: boolean;
  29100. /**
  29101. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29102. */
  29103. static AllowMatrixDecomposeForInterpolation: boolean;
  29104. /**
  29105. * Stores the key frames of the animation
  29106. */
  29107. private _keys;
  29108. /**
  29109. * Stores the easing function of the animation
  29110. */
  29111. private _easingFunction;
  29112. /**
  29113. * @hidden Internal use only
  29114. */
  29115. _runtimeAnimations: RuntimeAnimation[];
  29116. /**
  29117. * The set of event that will be linked to this animation
  29118. */
  29119. private _events;
  29120. /**
  29121. * Stores an array of target property paths
  29122. */
  29123. targetPropertyPath: string[];
  29124. /**
  29125. * Stores the blending speed of the animation
  29126. */
  29127. blendingSpeed: number;
  29128. /**
  29129. * Stores the animation ranges for the animation
  29130. */
  29131. private _ranges;
  29132. /**
  29133. * @hidden Internal use
  29134. */
  29135. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29136. /**
  29137. * Sets up an animation
  29138. * @param property The property to animate
  29139. * @param animationType The animation type to apply
  29140. * @param framePerSecond The frames per second of the animation
  29141. * @param easingFunction The easing function used in the animation
  29142. * @returns The created animation
  29143. */
  29144. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29145. /**
  29146. * Create and start an animation on a node
  29147. * @param name defines the name of the global animation that will be run on all nodes
  29148. * @param node defines the root node where the animation will take place
  29149. * @param targetProperty defines property to animate
  29150. * @param framePerSecond defines the number of frame per second yo use
  29151. * @param totalFrame defines the number of frames in total
  29152. * @param from defines the initial value
  29153. * @param to defines the final value
  29154. * @param loopMode defines which loop mode you want to use (off by default)
  29155. * @param easingFunction defines the easing function to use (linear by default)
  29156. * @param onAnimationEnd defines the callback to call when animation end
  29157. * @returns the animatable created for this animation
  29158. */
  29159. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29160. /**
  29161. * Create and start an animation on a node and its descendants
  29162. * @param name defines the name of the global animation that will be run on all nodes
  29163. * @param node defines the root node where the animation will take place
  29164. * @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
  29165. * @param targetProperty defines property to animate
  29166. * @param framePerSecond defines the number of frame per second to use
  29167. * @param totalFrame defines the number of frames in total
  29168. * @param from defines the initial value
  29169. * @param to defines the final value
  29170. * @param loopMode defines which loop mode you want to use (off by default)
  29171. * @param easingFunction defines the easing function to use (linear by default)
  29172. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29173. * @returns the list of animatables created for all nodes
  29174. * @example https://www.babylonjs-playground.com/#MH0VLI
  29175. */
  29176. 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[]>;
  29177. /**
  29178. * Creates a new animation, merges it with the existing animations and starts it
  29179. * @param name Name of the animation
  29180. * @param node Node which contains the scene that begins the animations
  29181. * @param targetProperty Specifies which property to animate
  29182. * @param framePerSecond The frames per second of the animation
  29183. * @param totalFrame The total number of frames
  29184. * @param from The frame at the beginning of the animation
  29185. * @param to The frame at the end of the animation
  29186. * @param loopMode Specifies the loop mode of the animation
  29187. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29188. * @param onAnimationEnd Callback to run once the animation is complete
  29189. * @returns Nullable animation
  29190. */
  29191. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29192. /**
  29193. * Transition property of an host to the target Value
  29194. * @param property The property to transition
  29195. * @param targetValue The target Value of the property
  29196. * @param host The object where the property to animate belongs
  29197. * @param scene Scene used to run the animation
  29198. * @param frameRate Framerate (in frame/s) to use
  29199. * @param transition The transition type we want to use
  29200. * @param duration The duration of the animation, in milliseconds
  29201. * @param onAnimationEnd Callback trigger at the end of the animation
  29202. * @returns Nullable animation
  29203. */
  29204. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29205. /**
  29206. * Return the array of runtime animations currently using this animation
  29207. */
  29208. get runtimeAnimations(): RuntimeAnimation[];
  29209. /**
  29210. * Specifies if any of the runtime animations are currently running
  29211. */
  29212. get hasRunningRuntimeAnimations(): boolean;
  29213. /**
  29214. * Initializes the animation
  29215. * @param name Name of the animation
  29216. * @param targetProperty Property to animate
  29217. * @param framePerSecond The frames per second of the animation
  29218. * @param dataType The data type of the animation
  29219. * @param loopMode The loop mode of the animation
  29220. * @param enableBlending Specifies if blending should be enabled
  29221. */
  29222. constructor(
  29223. /**Name of the animation */
  29224. name: string,
  29225. /**Property to animate */
  29226. targetProperty: string,
  29227. /**The frames per second of the animation */
  29228. framePerSecond: number,
  29229. /**The data type of the animation */
  29230. dataType: number,
  29231. /**The loop mode of the animation */
  29232. loopMode?: number | undefined,
  29233. /**Specifies if blending should be enabled */
  29234. enableBlending?: boolean | undefined);
  29235. /**
  29236. * Converts the animation to a string
  29237. * @param fullDetails support for multiple levels of logging within scene loading
  29238. * @returns String form of the animation
  29239. */
  29240. toString(fullDetails?: boolean): string;
  29241. /**
  29242. * Add an event to this animation
  29243. * @param event Event to add
  29244. */
  29245. addEvent(event: AnimationEvent): void;
  29246. /**
  29247. * Remove all events found at the given frame
  29248. * @param frame The frame to remove events from
  29249. */
  29250. removeEvents(frame: number): void;
  29251. /**
  29252. * Retrieves all the events from the animation
  29253. * @returns Events from the animation
  29254. */
  29255. getEvents(): AnimationEvent[];
  29256. /**
  29257. * Creates an animation range
  29258. * @param name Name of the animation range
  29259. * @param from Starting frame of the animation range
  29260. * @param to Ending frame of the animation
  29261. */
  29262. createRange(name: string, from: number, to: number): void;
  29263. /**
  29264. * Deletes an animation range by name
  29265. * @param name Name of the animation range to delete
  29266. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29267. */
  29268. deleteRange(name: string, deleteFrames?: boolean): void;
  29269. /**
  29270. * Gets the animation range by name, or null if not defined
  29271. * @param name Name of the animation range
  29272. * @returns Nullable animation range
  29273. */
  29274. getRange(name: string): Nullable<AnimationRange>;
  29275. /**
  29276. * Gets the key frames from the animation
  29277. * @returns The key frames of the animation
  29278. */
  29279. getKeys(): Array<IAnimationKey>;
  29280. /**
  29281. * Gets the highest frame rate of the animation
  29282. * @returns Highest frame rate of the animation
  29283. */
  29284. getHighestFrame(): number;
  29285. /**
  29286. * Gets the easing function of the animation
  29287. * @returns Easing function of the animation
  29288. */
  29289. getEasingFunction(): IEasingFunction;
  29290. /**
  29291. * Sets the easing function of the animation
  29292. * @param easingFunction A custom mathematical formula for animation
  29293. */
  29294. setEasingFunction(easingFunction: EasingFunction): void;
  29295. /**
  29296. * Interpolates a scalar linearly
  29297. * @param startValue Start value of the animation curve
  29298. * @param endValue End value of the animation curve
  29299. * @param gradient Scalar amount to interpolate
  29300. * @returns Interpolated scalar value
  29301. */
  29302. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29303. /**
  29304. * Interpolates a scalar cubically
  29305. * @param startValue Start value of the animation curve
  29306. * @param outTangent End tangent of the animation
  29307. * @param endValue End value of the animation curve
  29308. * @param inTangent Start tangent of the animation curve
  29309. * @param gradient Scalar amount to interpolate
  29310. * @returns Interpolated scalar value
  29311. */
  29312. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29313. /**
  29314. * Interpolates a quaternion using a spherical linear interpolation
  29315. * @param startValue Start value of the animation curve
  29316. * @param endValue End value of the animation curve
  29317. * @param gradient Scalar amount to interpolate
  29318. * @returns Interpolated quaternion value
  29319. */
  29320. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29321. /**
  29322. * Interpolates a quaternion cubically
  29323. * @param startValue Start value of the animation curve
  29324. * @param outTangent End tangent of the animation curve
  29325. * @param endValue End value of the animation curve
  29326. * @param inTangent Start tangent of the animation curve
  29327. * @param gradient Scalar amount to interpolate
  29328. * @returns Interpolated quaternion value
  29329. */
  29330. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29331. /**
  29332. * Interpolates a Vector3 linearl
  29333. * @param startValue Start value of the animation curve
  29334. * @param endValue End value of the animation curve
  29335. * @param gradient Scalar amount to interpolate
  29336. * @returns Interpolated scalar value
  29337. */
  29338. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29339. /**
  29340. * Interpolates a Vector3 cubically
  29341. * @param startValue Start value of the animation curve
  29342. * @param outTangent End tangent of the animation
  29343. * @param endValue End value of the animation curve
  29344. * @param inTangent Start tangent of the animation curve
  29345. * @param gradient Scalar amount to interpolate
  29346. * @returns InterpolatedVector3 value
  29347. */
  29348. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29349. /**
  29350. * Interpolates a Vector2 linearly
  29351. * @param startValue Start value of the animation curve
  29352. * @param endValue End value of the animation curve
  29353. * @param gradient Scalar amount to interpolate
  29354. * @returns Interpolated Vector2 value
  29355. */
  29356. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29357. /**
  29358. * Interpolates a Vector2 cubically
  29359. * @param startValue Start value of the animation curve
  29360. * @param outTangent End tangent of the animation
  29361. * @param endValue End value of the animation curve
  29362. * @param inTangent Start tangent of the animation curve
  29363. * @param gradient Scalar amount to interpolate
  29364. * @returns Interpolated Vector2 value
  29365. */
  29366. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29367. /**
  29368. * Interpolates a size linearly
  29369. * @param startValue Start value of the animation curve
  29370. * @param endValue End value of the animation curve
  29371. * @param gradient Scalar amount to interpolate
  29372. * @returns Interpolated Size value
  29373. */
  29374. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29375. /**
  29376. * Interpolates a Color3 linearly
  29377. * @param startValue Start value of the animation curve
  29378. * @param endValue End value of the animation curve
  29379. * @param gradient Scalar amount to interpolate
  29380. * @returns Interpolated Color3 value
  29381. */
  29382. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29383. /**
  29384. * Interpolates a Color4 linearly
  29385. * @param startValue Start value of the animation curve
  29386. * @param endValue End value of the animation curve
  29387. * @param gradient Scalar amount to interpolate
  29388. * @returns Interpolated Color3 value
  29389. */
  29390. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29391. /**
  29392. * @hidden Internal use only
  29393. */
  29394. _getKeyValue(value: any): any;
  29395. /**
  29396. * @hidden Internal use only
  29397. */
  29398. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29399. /**
  29400. * Defines the function to use to interpolate matrices
  29401. * @param startValue defines the start matrix
  29402. * @param endValue defines the end matrix
  29403. * @param gradient defines the gradient between both matrices
  29404. * @param result defines an optional target matrix where to store the interpolation
  29405. * @returns the interpolated matrix
  29406. */
  29407. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29408. /**
  29409. * Makes a copy of the animation
  29410. * @returns Cloned animation
  29411. */
  29412. clone(): Animation;
  29413. /**
  29414. * Sets the key frames of the animation
  29415. * @param values The animation key frames to set
  29416. */
  29417. setKeys(values: Array<IAnimationKey>): void;
  29418. /**
  29419. * Serializes the animation to an object
  29420. * @returns Serialized object
  29421. */
  29422. serialize(): any;
  29423. /**
  29424. * Float animation type
  29425. */
  29426. static readonly ANIMATIONTYPE_FLOAT: number;
  29427. /**
  29428. * Vector3 animation type
  29429. */
  29430. static readonly ANIMATIONTYPE_VECTOR3: number;
  29431. /**
  29432. * Quaternion animation type
  29433. */
  29434. static readonly ANIMATIONTYPE_QUATERNION: number;
  29435. /**
  29436. * Matrix animation type
  29437. */
  29438. static readonly ANIMATIONTYPE_MATRIX: number;
  29439. /**
  29440. * Color3 animation type
  29441. */
  29442. static readonly ANIMATIONTYPE_COLOR3: number;
  29443. /**
  29444. * Color3 animation type
  29445. */
  29446. static readonly ANIMATIONTYPE_COLOR4: number;
  29447. /**
  29448. * Vector2 animation type
  29449. */
  29450. static readonly ANIMATIONTYPE_VECTOR2: number;
  29451. /**
  29452. * Size animation type
  29453. */
  29454. static readonly ANIMATIONTYPE_SIZE: number;
  29455. /**
  29456. * Relative Loop Mode
  29457. */
  29458. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29459. /**
  29460. * Cycle Loop Mode
  29461. */
  29462. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29463. /**
  29464. * Constant Loop Mode
  29465. */
  29466. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29467. /** @hidden */
  29468. static _UniversalLerp(left: any, right: any, amount: number): any;
  29469. /**
  29470. * Parses an animation object and creates an animation
  29471. * @param parsedAnimation Parsed animation object
  29472. * @returns Animation object
  29473. */
  29474. static Parse(parsedAnimation: any): Animation;
  29475. /**
  29476. * Appends the serialized animations from the source animations
  29477. * @param source Source containing the animations
  29478. * @param destination Target to store the animations
  29479. */
  29480. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29481. }
  29482. }
  29483. declare module BABYLON {
  29484. /**
  29485. * Interface containing an array of animations
  29486. */
  29487. export interface IAnimatable {
  29488. /**
  29489. * Array of animations
  29490. */
  29491. animations: Nullable<Array<Animation>>;
  29492. }
  29493. }
  29494. declare module BABYLON {
  29495. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29496. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29502. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29503. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29504. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29505. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29506. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29507. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29508. /**
  29509. * Decorator used to define property that can be serialized as reference to a camera
  29510. * @param sourceName defines the name of the property to decorate
  29511. */
  29512. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29513. /**
  29514. * Class used to help serialization objects
  29515. */
  29516. export class SerializationHelper {
  29517. /** @hidden */
  29518. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29519. /** @hidden */
  29520. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29521. /** @hidden */
  29522. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29523. /** @hidden */
  29524. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29525. /**
  29526. * Appends the serialized animations from the source animations
  29527. * @param source Source containing the animations
  29528. * @param destination Target to store the animations
  29529. */
  29530. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29531. /**
  29532. * Static function used to serialized a specific entity
  29533. * @param entity defines the entity to serialize
  29534. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29535. * @returns a JSON compatible object representing the serialization of the entity
  29536. */
  29537. static Serialize<T>(entity: T, serializationObject?: any): any;
  29538. /**
  29539. * Creates a new entity from a serialization data object
  29540. * @param creationFunction defines a function used to instanciated the new entity
  29541. * @param source defines the source serialization data
  29542. * @param scene defines the hosting scene
  29543. * @param rootUrl defines the root url for resources
  29544. * @returns a new entity
  29545. */
  29546. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29547. /**
  29548. * Clones an object
  29549. * @param creationFunction defines the function used to instanciate the new object
  29550. * @param source defines the source object
  29551. * @returns the cloned object
  29552. */
  29553. static Clone<T>(creationFunction: () => T, source: T): T;
  29554. /**
  29555. * Instanciates a new object based on a source one (some data will be shared between both object)
  29556. * @param creationFunction defines the function used to instanciate the new object
  29557. * @param source defines the source object
  29558. * @returns the new object
  29559. */
  29560. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29561. }
  29562. }
  29563. declare module BABYLON {
  29564. /**
  29565. * Class used to manipulate GUIDs
  29566. */
  29567. export class GUID {
  29568. /**
  29569. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29570. * Be aware Math.random() could cause collisions, but:
  29571. * "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"
  29572. * @returns a pseudo random id
  29573. */
  29574. static RandomId(): string;
  29575. }
  29576. }
  29577. declare module BABYLON {
  29578. /**
  29579. * Base class of all the textures in babylon.
  29580. * It groups all the common properties the materials, post process, lights... might need
  29581. * in order to make a correct use of the texture.
  29582. */
  29583. export class BaseTexture implements IAnimatable {
  29584. /**
  29585. * Default anisotropic filtering level for the application.
  29586. * It is set to 4 as a good tradeoff between perf and quality.
  29587. */
  29588. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29589. /**
  29590. * Gets or sets the unique id of the texture
  29591. */
  29592. uniqueId: number;
  29593. /**
  29594. * Define the name of the texture.
  29595. */
  29596. name: string;
  29597. /**
  29598. * Gets or sets an object used to store user defined information.
  29599. */
  29600. metadata: any;
  29601. /**
  29602. * For internal use only. Please do not use.
  29603. */
  29604. reservedDataStore: any;
  29605. private _hasAlpha;
  29606. /**
  29607. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29608. */
  29609. set hasAlpha(value: boolean);
  29610. get hasAlpha(): boolean;
  29611. /**
  29612. * Defines if the alpha value should be determined via the rgb values.
  29613. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29614. */
  29615. getAlphaFromRGB: boolean;
  29616. /**
  29617. * Intensity or strength of the texture.
  29618. * It is commonly used by materials to fine tune the intensity of the texture
  29619. */
  29620. level: number;
  29621. /**
  29622. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29623. * This is part of the texture as textures usually maps to one uv set.
  29624. */
  29625. coordinatesIndex: number;
  29626. private _coordinatesMode;
  29627. /**
  29628. * How a texture is mapped.
  29629. *
  29630. * | Value | Type | Description |
  29631. * | ----- | ----------------------------------- | ----------- |
  29632. * | 0 | EXPLICIT_MODE | |
  29633. * | 1 | SPHERICAL_MODE | |
  29634. * | 2 | PLANAR_MODE | |
  29635. * | 3 | CUBIC_MODE | |
  29636. * | 4 | PROJECTION_MODE | |
  29637. * | 5 | SKYBOX_MODE | |
  29638. * | 6 | INVCUBIC_MODE | |
  29639. * | 7 | EQUIRECTANGULAR_MODE | |
  29640. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29641. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29642. */
  29643. set coordinatesMode(value: number);
  29644. get coordinatesMode(): number;
  29645. /**
  29646. * | Value | Type | Description |
  29647. * | ----- | ------------------ | ----------- |
  29648. * | 0 | CLAMP_ADDRESSMODE | |
  29649. * | 1 | WRAP_ADDRESSMODE | |
  29650. * | 2 | MIRROR_ADDRESSMODE | |
  29651. */
  29652. wrapU: number;
  29653. /**
  29654. * | Value | Type | Description |
  29655. * | ----- | ------------------ | ----------- |
  29656. * | 0 | CLAMP_ADDRESSMODE | |
  29657. * | 1 | WRAP_ADDRESSMODE | |
  29658. * | 2 | MIRROR_ADDRESSMODE | |
  29659. */
  29660. wrapV: number;
  29661. /**
  29662. * | Value | Type | Description |
  29663. * | ----- | ------------------ | ----------- |
  29664. * | 0 | CLAMP_ADDRESSMODE | |
  29665. * | 1 | WRAP_ADDRESSMODE | |
  29666. * | 2 | MIRROR_ADDRESSMODE | |
  29667. */
  29668. wrapR: number;
  29669. /**
  29670. * With compliant hardware and browser (supporting anisotropic filtering)
  29671. * this defines the level of anisotropic filtering in the texture.
  29672. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29673. */
  29674. anisotropicFilteringLevel: number;
  29675. /**
  29676. * Define if the texture is a cube texture or if false a 2d texture.
  29677. */
  29678. get isCube(): boolean;
  29679. set isCube(value: boolean);
  29680. /**
  29681. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29682. */
  29683. get is3D(): boolean;
  29684. set is3D(value: boolean);
  29685. /**
  29686. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29687. */
  29688. get is2DArray(): boolean;
  29689. set is2DArray(value: boolean);
  29690. /**
  29691. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29692. * HDR texture are usually stored in linear space.
  29693. * This only impacts the PBR and Background materials
  29694. */
  29695. gammaSpace: boolean;
  29696. /**
  29697. * Gets or sets whether or not the texture contains RGBD data.
  29698. */
  29699. get isRGBD(): boolean;
  29700. set isRGBD(value: boolean);
  29701. /**
  29702. * Is Z inverted in the texture (useful in a cube texture).
  29703. */
  29704. invertZ: boolean;
  29705. /**
  29706. * Are mip maps generated for this texture or not.
  29707. */
  29708. get noMipmap(): boolean;
  29709. /**
  29710. * @hidden
  29711. */
  29712. lodLevelInAlpha: boolean;
  29713. /**
  29714. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29715. */
  29716. get lodGenerationOffset(): number;
  29717. set lodGenerationOffset(value: number);
  29718. /**
  29719. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29720. */
  29721. get lodGenerationScale(): number;
  29722. set lodGenerationScale(value: number);
  29723. /**
  29724. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29725. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29726. * average roughness values.
  29727. */
  29728. get linearSpecularLOD(): boolean;
  29729. set linearSpecularLOD(value: boolean);
  29730. /**
  29731. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29732. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29733. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29734. */
  29735. get irradianceTexture(): Nullable<BaseTexture>;
  29736. set irradianceTexture(value: Nullable<BaseTexture>);
  29737. /**
  29738. * Define if the texture is a render target.
  29739. */
  29740. isRenderTarget: boolean;
  29741. /**
  29742. * Define the unique id of the texture in the scene.
  29743. */
  29744. get uid(): string;
  29745. /**
  29746. * Return a string representation of the texture.
  29747. * @returns the texture as a string
  29748. */
  29749. toString(): string;
  29750. /**
  29751. * Get the class name of the texture.
  29752. * @returns "BaseTexture"
  29753. */
  29754. getClassName(): string;
  29755. /**
  29756. * Define the list of animation attached to the texture.
  29757. */
  29758. animations: Animation[];
  29759. /**
  29760. * An event triggered when the texture is disposed.
  29761. */
  29762. onDisposeObservable: Observable<BaseTexture>;
  29763. private _onDisposeObserver;
  29764. /**
  29765. * Callback triggered when the texture has been disposed.
  29766. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29767. */
  29768. set onDispose(callback: () => void);
  29769. /**
  29770. * Define the current state of the loading sequence when in delayed load mode.
  29771. */
  29772. delayLoadState: number;
  29773. private _scene;
  29774. /** @hidden */
  29775. _texture: Nullable<InternalTexture>;
  29776. private _uid;
  29777. /**
  29778. * Define if the texture is preventinga material to render or not.
  29779. * If not and the texture is not ready, the engine will use a default black texture instead.
  29780. */
  29781. get isBlocking(): boolean;
  29782. /**
  29783. * Instantiates a new BaseTexture.
  29784. * Base class of all the textures in babylon.
  29785. * It groups all the common properties the materials, post process, lights... might need
  29786. * in order to make a correct use of the texture.
  29787. * @param scene Define the scene the texture blongs to
  29788. */
  29789. constructor(scene: Nullable<Scene>);
  29790. /**
  29791. * Get the scene the texture belongs to.
  29792. * @returns the scene or null if undefined
  29793. */
  29794. getScene(): Nullable<Scene>;
  29795. /**
  29796. * Get the texture transform matrix used to offset tile the texture for istance.
  29797. * @returns the transformation matrix
  29798. */
  29799. getTextureMatrix(): Matrix;
  29800. /**
  29801. * Get the texture reflection matrix used to rotate/transform the reflection.
  29802. * @returns the reflection matrix
  29803. */
  29804. getReflectionTextureMatrix(): Matrix;
  29805. /**
  29806. * Get the underlying lower level texture from Babylon.
  29807. * @returns the insternal texture
  29808. */
  29809. getInternalTexture(): Nullable<InternalTexture>;
  29810. /**
  29811. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29812. * @returns true if ready or not blocking
  29813. */
  29814. isReadyOrNotBlocking(): boolean;
  29815. /**
  29816. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29817. * @returns true if fully ready
  29818. */
  29819. isReady(): boolean;
  29820. private _cachedSize;
  29821. /**
  29822. * Get the size of the texture.
  29823. * @returns the texture size.
  29824. */
  29825. getSize(): ISize;
  29826. /**
  29827. * Get the base size of the texture.
  29828. * It can be different from the size if the texture has been resized for POT for instance
  29829. * @returns the base size
  29830. */
  29831. getBaseSize(): ISize;
  29832. /**
  29833. * Update the sampling mode of the texture.
  29834. * Default is Trilinear mode.
  29835. *
  29836. * | Value | Type | Description |
  29837. * | ----- | ------------------ | ----------- |
  29838. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29839. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29840. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29841. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29842. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29843. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29844. * | 7 | NEAREST_LINEAR | |
  29845. * | 8 | NEAREST_NEAREST | |
  29846. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29847. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29848. * | 11 | LINEAR_LINEAR | |
  29849. * | 12 | LINEAR_NEAREST | |
  29850. *
  29851. * > _mag_: magnification filter (close to the viewer)
  29852. * > _min_: minification filter (far from the viewer)
  29853. * > _mip_: filter used between mip map levels
  29854. *@param samplingMode Define the new sampling mode of the texture
  29855. */
  29856. updateSamplingMode(samplingMode: number): void;
  29857. /**
  29858. * Scales the texture if is `canRescale()`
  29859. * @param ratio the resize factor we want to use to rescale
  29860. */
  29861. scale(ratio: number): void;
  29862. /**
  29863. * Get if the texture can rescale.
  29864. */
  29865. get canRescale(): boolean;
  29866. /** @hidden */
  29867. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29868. /** @hidden */
  29869. _rebuild(): void;
  29870. /**
  29871. * Triggers the load sequence in delayed load mode.
  29872. */
  29873. delayLoad(): void;
  29874. /**
  29875. * Clones the texture.
  29876. * @returns the cloned texture
  29877. */
  29878. clone(): Nullable<BaseTexture>;
  29879. /**
  29880. * Get the texture underlying type (INT, FLOAT...)
  29881. */
  29882. get textureType(): number;
  29883. /**
  29884. * Get the texture underlying format (RGB, RGBA...)
  29885. */
  29886. get textureFormat(): number;
  29887. /**
  29888. * Indicates that textures need to be re-calculated for all materials
  29889. */
  29890. protected _markAllSubMeshesAsTexturesDirty(): void;
  29891. /**
  29892. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29893. * This will returns an RGBA array buffer containing either in values (0-255) or
  29894. * float values (0-1) depending of the underlying buffer type.
  29895. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29896. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29897. * @param buffer defines a user defined buffer to fill with data (can be null)
  29898. * @returns The Array buffer containing the pixels data.
  29899. */
  29900. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29901. /**
  29902. * Release and destroy the underlying lower level texture aka internalTexture.
  29903. */
  29904. releaseInternalTexture(): void;
  29905. /** @hidden */
  29906. get _lodTextureHigh(): Nullable<BaseTexture>;
  29907. /** @hidden */
  29908. get _lodTextureMid(): Nullable<BaseTexture>;
  29909. /** @hidden */
  29910. get _lodTextureLow(): Nullable<BaseTexture>;
  29911. /**
  29912. * Dispose the texture and release its associated resources.
  29913. */
  29914. dispose(): void;
  29915. /**
  29916. * Serialize the texture into a JSON representation that can be parsed later on.
  29917. * @returns the JSON representation of the texture
  29918. */
  29919. serialize(): any;
  29920. /**
  29921. * Helper function to be called back once a list of texture contains only ready textures.
  29922. * @param textures Define the list of textures to wait for
  29923. * @param callback Define the callback triggered once the entire list will be ready
  29924. */
  29925. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29926. }
  29927. }
  29928. declare module BABYLON {
  29929. /**
  29930. * Options to be used when creating an effect.
  29931. */
  29932. export interface IEffectCreationOptions {
  29933. /**
  29934. * Atrributes that will be used in the shader.
  29935. */
  29936. attributes: string[];
  29937. /**
  29938. * Uniform varible names that will be set in the shader.
  29939. */
  29940. uniformsNames: string[];
  29941. /**
  29942. * Uniform buffer variable names that will be set in the shader.
  29943. */
  29944. uniformBuffersNames: string[];
  29945. /**
  29946. * Sampler texture variable names that will be set in the shader.
  29947. */
  29948. samplers: string[];
  29949. /**
  29950. * Define statements that will be set in the shader.
  29951. */
  29952. defines: any;
  29953. /**
  29954. * Possible fallbacks for this effect to improve performance when needed.
  29955. */
  29956. fallbacks: Nullable<IEffectFallbacks>;
  29957. /**
  29958. * Callback that will be called when the shader is compiled.
  29959. */
  29960. onCompiled: Nullable<(effect: Effect) => void>;
  29961. /**
  29962. * Callback that will be called if an error occurs during shader compilation.
  29963. */
  29964. onError: Nullable<(effect: Effect, errors: string) => void>;
  29965. /**
  29966. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29967. */
  29968. indexParameters?: any;
  29969. /**
  29970. * Max number of lights that can be used in the shader.
  29971. */
  29972. maxSimultaneousLights?: number;
  29973. /**
  29974. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29975. */
  29976. transformFeedbackVaryings?: Nullable<string[]>;
  29977. }
  29978. /**
  29979. * Effect containing vertex and fragment shader that can be executed on an object.
  29980. */
  29981. export class Effect implements IDisposable {
  29982. /**
  29983. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29984. */
  29985. static ShadersRepository: string;
  29986. /**
  29987. * Name of the effect.
  29988. */
  29989. name: any;
  29990. /**
  29991. * String container all the define statements that should be set on the shader.
  29992. */
  29993. defines: string;
  29994. /**
  29995. * Callback that will be called when the shader is compiled.
  29996. */
  29997. onCompiled: Nullable<(effect: Effect) => void>;
  29998. /**
  29999. * Callback that will be called if an error occurs during shader compilation.
  30000. */
  30001. onError: Nullable<(effect: Effect, errors: string) => void>;
  30002. /**
  30003. * Callback that will be called when effect is bound.
  30004. */
  30005. onBind: Nullable<(effect: Effect) => void>;
  30006. /**
  30007. * Unique ID of the effect.
  30008. */
  30009. uniqueId: number;
  30010. /**
  30011. * Observable that will be called when the shader is compiled.
  30012. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30013. */
  30014. onCompileObservable: Observable<Effect>;
  30015. /**
  30016. * Observable that will be called if an error occurs during shader compilation.
  30017. */
  30018. onErrorObservable: Observable<Effect>;
  30019. /** @hidden */
  30020. _onBindObservable: Nullable<Observable<Effect>>;
  30021. /**
  30022. * @hidden
  30023. * Specifies if the effect was previously ready
  30024. */
  30025. _wasPreviouslyReady: boolean;
  30026. /**
  30027. * Observable that will be called when effect is bound.
  30028. */
  30029. get onBindObservable(): Observable<Effect>;
  30030. /** @hidden */
  30031. _bonesComputationForcedToCPU: boolean;
  30032. private static _uniqueIdSeed;
  30033. private _engine;
  30034. private _uniformBuffersNames;
  30035. private _uniformsNames;
  30036. private _samplerList;
  30037. private _samplers;
  30038. private _isReady;
  30039. private _compilationError;
  30040. private _allFallbacksProcessed;
  30041. private _attributesNames;
  30042. private _attributes;
  30043. private _attributeLocationByName;
  30044. private _uniforms;
  30045. /**
  30046. * Key for the effect.
  30047. * @hidden
  30048. */
  30049. _key: string;
  30050. private _indexParameters;
  30051. private _fallbacks;
  30052. private _vertexSourceCode;
  30053. private _fragmentSourceCode;
  30054. private _vertexSourceCodeOverride;
  30055. private _fragmentSourceCodeOverride;
  30056. private _transformFeedbackVaryings;
  30057. /**
  30058. * Compiled shader to webGL program.
  30059. * @hidden
  30060. */
  30061. _pipelineContext: Nullable<IPipelineContext>;
  30062. private _valueCache;
  30063. private static _baseCache;
  30064. /**
  30065. * Instantiates an effect.
  30066. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30067. * @param baseName Name of the effect.
  30068. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30069. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30070. * @param samplers List of sampler variables that will be passed to the shader.
  30071. * @param engine Engine to be used to render the effect
  30072. * @param defines Define statements to be added to the shader.
  30073. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30074. * @param onCompiled Callback that will be called when the shader is compiled.
  30075. * @param onError Callback that will be called if an error occurs during shader compilation.
  30076. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30077. */
  30078. 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);
  30079. private _useFinalCode;
  30080. /**
  30081. * Unique key for this effect
  30082. */
  30083. get key(): string;
  30084. /**
  30085. * If the effect has been compiled and prepared.
  30086. * @returns if the effect is compiled and prepared.
  30087. */
  30088. isReady(): boolean;
  30089. private _isReadyInternal;
  30090. /**
  30091. * The engine the effect was initialized with.
  30092. * @returns the engine.
  30093. */
  30094. getEngine(): Engine;
  30095. /**
  30096. * The pipeline context for this effect
  30097. * @returns the associated pipeline context
  30098. */
  30099. getPipelineContext(): Nullable<IPipelineContext>;
  30100. /**
  30101. * The set of names of attribute variables for the shader.
  30102. * @returns An array of attribute names.
  30103. */
  30104. getAttributesNames(): string[];
  30105. /**
  30106. * Returns the attribute at the given index.
  30107. * @param index The index of the attribute.
  30108. * @returns The location of the attribute.
  30109. */
  30110. getAttributeLocation(index: number): number;
  30111. /**
  30112. * Returns the attribute based on the name of the variable.
  30113. * @param name of the attribute to look up.
  30114. * @returns the attribute location.
  30115. */
  30116. getAttributeLocationByName(name: string): number;
  30117. /**
  30118. * The number of attributes.
  30119. * @returns the numnber of attributes.
  30120. */
  30121. getAttributesCount(): number;
  30122. /**
  30123. * Gets the index of a uniform variable.
  30124. * @param uniformName of the uniform to look up.
  30125. * @returns the index.
  30126. */
  30127. getUniformIndex(uniformName: string): number;
  30128. /**
  30129. * Returns the attribute based on the name of the variable.
  30130. * @param uniformName of the uniform to look up.
  30131. * @returns the location of the uniform.
  30132. */
  30133. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30134. /**
  30135. * Returns an array of sampler variable names
  30136. * @returns The array of sampler variable neames.
  30137. */
  30138. getSamplers(): string[];
  30139. /**
  30140. * The error from the last compilation.
  30141. * @returns the error string.
  30142. */
  30143. getCompilationError(): string;
  30144. /**
  30145. * Gets a boolean indicating that all fallbacks were used during compilation
  30146. * @returns true if all fallbacks were used
  30147. */
  30148. allFallbacksProcessed(): boolean;
  30149. /**
  30150. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30151. * @param func The callback to be used.
  30152. */
  30153. executeWhenCompiled(func: (effect: Effect) => void): void;
  30154. private _checkIsReady;
  30155. private _loadShader;
  30156. /**
  30157. * Recompiles the webGL program
  30158. * @param vertexSourceCode The source code for the vertex shader.
  30159. * @param fragmentSourceCode The source code for the fragment shader.
  30160. * @param onCompiled Callback called when completed.
  30161. * @param onError Callback called on error.
  30162. * @hidden
  30163. */
  30164. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30165. /**
  30166. * Prepares the effect
  30167. * @hidden
  30168. */
  30169. _prepareEffect(): void;
  30170. private _processCompilationErrors;
  30171. /**
  30172. * Checks if the effect is supported. (Must be called after compilation)
  30173. */
  30174. get isSupported(): boolean;
  30175. /**
  30176. * Binds a texture to the engine to be used as output of the shader.
  30177. * @param channel Name of the output variable.
  30178. * @param texture Texture to bind.
  30179. * @hidden
  30180. */
  30181. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30182. /**
  30183. * Sets a texture on the engine to be used in the shader.
  30184. * @param channel Name of the sampler variable.
  30185. * @param texture Texture to set.
  30186. */
  30187. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30188. /**
  30189. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30190. * @param channel Name of the sampler variable.
  30191. * @param texture Texture to set.
  30192. */
  30193. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30194. /**
  30195. * Sets an array of textures on the engine to be used in the shader.
  30196. * @param channel Name of the variable.
  30197. * @param textures Textures to set.
  30198. */
  30199. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30200. /**
  30201. * 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)
  30202. * @param channel Name of the sampler variable.
  30203. * @param postProcess Post process to get the input texture from.
  30204. */
  30205. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30206. /**
  30207. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30208. * 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)
  30209. * @param channel Name of the sampler variable.
  30210. * @param postProcess Post process to get the output texture from.
  30211. */
  30212. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30213. /** @hidden */
  30214. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30215. /** @hidden */
  30216. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30217. /** @hidden */
  30218. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30219. /** @hidden */
  30220. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30221. /**
  30222. * Binds a buffer to a uniform.
  30223. * @param buffer Buffer to bind.
  30224. * @param name Name of the uniform variable to bind to.
  30225. */
  30226. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30227. /**
  30228. * Binds block to a uniform.
  30229. * @param blockName Name of the block to bind.
  30230. * @param index Index to bind.
  30231. */
  30232. bindUniformBlock(blockName: string, index: number): void;
  30233. /**
  30234. * Sets an interger value on a uniform variable.
  30235. * @param uniformName Name of the variable.
  30236. * @param value Value to be set.
  30237. * @returns this effect.
  30238. */
  30239. setInt(uniformName: string, value: number): Effect;
  30240. /**
  30241. * Sets an int array on a uniform variable.
  30242. * @param uniformName Name of the variable.
  30243. * @param array array to be set.
  30244. * @returns this effect.
  30245. */
  30246. setIntArray(uniformName: string, array: Int32Array): Effect;
  30247. /**
  30248. * 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)
  30249. * @param uniformName Name of the variable.
  30250. * @param array array to be set.
  30251. * @returns this effect.
  30252. */
  30253. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30254. /**
  30255. * 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)
  30256. * @param uniformName Name of the variable.
  30257. * @param array array to be set.
  30258. * @returns this effect.
  30259. */
  30260. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30261. /**
  30262. * 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)
  30263. * @param uniformName Name of the variable.
  30264. * @param array array to be set.
  30265. * @returns this effect.
  30266. */
  30267. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30268. /**
  30269. * Sets an float array on a uniform variable.
  30270. * @param uniformName Name of the variable.
  30271. * @param array array to be set.
  30272. * @returns this effect.
  30273. */
  30274. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30275. /**
  30276. * 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)
  30277. * @param uniformName Name of the variable.
  30278. * @param array array to be set.
  30279. * @returns this effect.
  30280. */
  30281. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30282. /**
  30283. * 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)
  30284. * @param uniformName Name of the variable.
  30285. * @param array array to be set.
  30286. * @returns this effect.
  30287. */
  30288. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30289. /**
  30290. * 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)
  30291. * @param uniformName Name of the variable.
  30292. * @param array array to be set.
  30293. * @returns this effect.
  30294. */
  30295. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30296. /**
  30297. * Sets an array on a uniform variable.
  30298. * @param uniformName Name of the variable.
  30299. * @param array array to be set.
  30300. * @returns this effect.
  30301. */
  30302. setArray(uniformName: string, array: number[]): Effect;
  30303. /**
  30304. * 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)
  30305. * @param uniformName Name of the variable.
  30306. * @param array array to be set.
  30307. * @returns this effect.
  30308. */
  30309. setArray2(uniformName: string, array: number[]): Effect;
  30310. /**
  30311. * 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)
  30312. * @param uniformName Name of the variable.
  30313. * @param array array to be set.
  30314. * @returns this effect.
  30315. */
  30316. setArray3(uniformName: string, array: number[]): Effect;
  30317. /**
  30318. * 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)
  30319. * @param uniformName Name of the variable.
  30320. * @param array array to be set.
  30321. * @returns this effect.
  30322. */
  30323. setArray4(uniformName: string, array: number[]): Effect;
  30324. /**
  30325. * Sets matrices on a uniform variable.
  30326. * @param uniformName Name of the variable.
  30327. * @param matrices matrices to be set.
  30328. * @returns this effect.
  30329. */
  30330. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30331. /**
  30332. * Sets matrix on a uniform variable.
  30333. * @param uniformName Name of the variable.
  30334. * @param matrix matrix to be set.
  30335. * @returns this effect.
  30336. */
  30337. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30338. /**
  30339. * 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)
  30340. * @param uniformName Name of the variable.
  30341. * @param matrix matrix to be set.
  30342. * @returns this effect.
  30343. */
  30344. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30345. /**
  30346. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30347. * @param uniformName Name of the variable.
  30348. * @param matrix matrix to be set.
  30349. * @returns this effect.
  30350. */
  30351. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30352. /**
  30353. * Sets a float on a uniform variable.
  30354. * @param uniformName Name of the variable.
  30355. * @param value value to be set.
  30356. * @returns this effect.
  30357. */
  30358. setFloat(uniformName: string, value: number): Effect;
  30359. /**
  30360. * Sets a boolean on a uniform variable.
  30361. * @param uniformName Name of the variable.
  30362. * @param bool value to be set.
  30363. * @returns this effect.
  30364. */
  30365. setBool(uniformName: string, bool: boolean): Effect;
  30366. /**
  30367. * Sets a Vector2 on a uniform variable.
  30368. * @param uniformName Name of the variable.
  30369. * @param vector2 vector2 to be set.
  30370. * @returns this effect.
  30371. */
  30372. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30373. /**
  30374. * Sets a float2 on a uniform variable.
  30375. * @param uniformName Name of the variable.
  30376. * @param x First float in float2.
  30377. * @param y Second float in float2.
  30378. * @returns this effect.
  30379. */
  30380. setFloat2(uniformName: string, x: number, y: number): Effect;
  30381. /**
  30382. * Sets a Vector3 on a uniform variable.
  30383. * @param uniformName Name of the variable.
  30384. * @param vector3 Value to be set.
  30385. * @returns this effect.
  30386. */
  30387. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30388. /**
  30389. * Sets a float3 on a uniform variable.
  30390. * @param uniformName Name of the variable.
  30391. * @param x First float in float3.
  30392. * @param y Second float in float3.
  30393. * @param z Third float in float3.
  30394. * @returns this effect.
  30395. */
  30396. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30397. /**
  30398. * Sets a Vector4 on a uniform variable.
  30399. * @param uniformName Name of the variable.
  30400. * @param vector4 Value to be set.
  30401. * @returns this effect.
  30402. */
  30403. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30404. /**
  30405. * Sets a float4 on a uniform variable.
  30406. * @param uniformName Name of the variable.
  30407. * @param x First float in float4.
  30408. * @param y Second float in float4.
  30409. * @param z Third float in float4.
  30410. * @param w Fourth float in float4.
  30411. * @returns this effect.
  30412. */
  30413. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30414. /**
  30415. * Sets a Color3 on a uniform variable.
  30416. * @param uniformName Name of the variable.
  30417. * @param color3 Value to be set.
  30418. * @returns this effect.
  30419. */
  30420. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30421. /**
  30422. * Sets a Color4 on a uniform variable.
  30423. * @param uniformName Name of the variable.
  30424. * @param color3 Value to be set.
  30425. * @param alpha Alpha value to be set.
  30426. * @returns this effect.
  30427. */
  30428. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30429. /**
  30430. * Sets a Color4 on a uniform variable
  30431. * @param uniformName defines the name of the variable
  30432. * @param color4 defines the value to be set
  30433. * @returns this effect.
  30434. */
  30435. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30436. /** Release all associated resources */
  30437. dispose(): void;
  30438. /**
  30439. * This function will add a new shader to the shader store
  30440. * @param name the name of the shader
  30441. * @param pixelShader optional pixel shader content
  30442. * @param vertexShader optional vertex shader content
  30443. */
  30444. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30445. /**
  30446. * Store of each shader (The can be looked up using effect.key)
  30447. */
  30448. static ShadersStore: {
  30449. [key: string]: string;
  30450. };
  30451. /**
  30452. * Store of each included file for a shader (The can be looked up using effect.key)
  30453. */
  30454. static IncludesShadersStore: {
  30455. [key: string]: string;
  30456. };
  30457. /**
  30458. * Resets the cache of effects.
  30459. */
  30460. static ResetCache(): void;
  30461. }
  30462. }
  30463. declare module BABYLON {
  30464. /**
  30465. * Interface used to describe the capabilities of the engine relatively to the current browser
  30466. */
  30467. export interface EngineCapabilities {
  30468. /** Maximum textures units per fragment shader */
  30469. maxTexturesImageUnits: number;
  30470. /** Maximum texture units per vertex shader */
  30471. maxVertexTextureImageUnits: number;
  30472. /** Maximum textures units in the entire pipeline */
  30473. maxCombinedTexturesImageUnits: number;
  30474. /** Maximum texture size */
  30475. maxTextureSize: number;
  30476. /** Maximum texture samples */
  30477. maxSamples?: number;
  30478. /** Maximum cube texture size */
  30479. maxCubemapTextureSize: number;
  30480. /** Maximum render texture size */
  30481. maxRenderTextureSize: number;
  30482. /** Maximum number of vertex attributes */
  30483. maxVertexAttribs: number;
  30484. /** Maximum number of varyings */
  30485. maxVaryingVectors: number;
  30486. /** Maximum number of uniforms per vertex shader */
  30487. maxVertexUniformVectors: number;
  30488. /** Maximum number of uniforms per fragment shader */
  30489. maxFragmentUniformVectors: number;
  30490. /** Defines if standard derivates (dx/dy) are supported */
  30491. standardDerivatives: boolean;
  30492. /** Defines if s3tc texture compression is supported */
  30493. s3tc?: WEBGL_compressed_texture_s3tc;
  30494. /** Defines if pvrtc texture compression is supported */
  30495. pvrtc: any;
  30496. /** Defines if etc1 texture compression is supported */
  30497. etc1: any;
  30498. /** Defines if etc2 texture compression is supported */
  30499. etc2: any;
  30500. /** Defines if astc texture compression is supported */
  30501. astc: any;
  30502. /** Defines if float textures are supported */
  30503. textureFloat: boolean;
  30504. /** Defines if vertex array objects are supported */
  30505. vertexArrayObject: boolean;
  30506. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30507. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30508. /** Gets the maximum level of anisotropy supported */
  30509. maxAnisotropy: number;
  30510. /** Defines if instancing is supported */
  30511. instancedArrays: boolean;
  30512. /** Defines if 32 bits indices are supported */
  30513. uintIndices: boolean;
  30514. /** Defines if high precision shaders are supported */
  30515. highPrecisionShaderSupported: boolean;
  30516. /** Defines if depth reading in the fragment shader is supported */
  30517. fragmentDepthSupported: boolean;
  30518. /** Defines if float texture linear filtering is supported*/
  30519. textureFloatLinearFiltering: boolean;
  30520. /** Defines if rendering to float textures is supported */
  30521. textureFloatRender: boolean;
  30522. /** Defines if half float textures are supported*/
  30523. textureHalfFloat: boolean;
  30524. /** Defines if half float texture linear filtering is supported*/
  30525. textureHalfFloatLinearFiltering: boolean;
  30526. /** Defines if rendering to half float textures is supported */
  30527. textureHalfFloatRender: boolean;
  30528. /** Defines if textureLOD shader command is supported */
  30529. textureLOD: boolean;
  30530. /** Defines if draw buffers extension is supported */
  30531. drawBuffersExtension: boolean;
  30532. /** Defines if depth textures are supported */
  30533. depthTextureExtension: boolean;
  30534. /** Defines if float color buffer are supported */
  30535. colorBufferFloat: boolean;
  30536. /** Gets disjoint timer query extension (null if not supported) */
  30537. timerQuery?: EXT_disjoint_timer_query;
  30538. /** Defines if timestamp can be used with timer query */
  30539. canUseTimestampForTimerQuery: boolean;
  30540. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30541. multiview?: any;
  30542. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30543. oculusMultiview?: any;
  30544. /** Function used to let the system compiles shaders in background */
  30545. parallelShaderCompile?: {
  30546. COMPLETION_STATUS_KHR: number;
  30547. };
  30548. /** Max number of texture samples for MSAA */
  30549. maxMSAASamples: number;
  30550. /** Defines if the blend min max extension is supported */
  30551. blendMinMax: boolean;
  30552. }
  30553. }
  30554. declare module BABYLON {
  30555. /**
  30556. * @hidden
  30557. **/
  30558. export class DepthCullingState {
  30559. private _isDepthTestDirty;
  30560. private _isDepthMaskDirty;
  30561. private _isDepthFuncDirty;
  30562. private _isCullFaceDirty;
  30563. private _isCullDirty;
  30564. private _isZOffsetDirty;
  30565. private _isFrontFaceDirty;
  30566. private _depthTest;
  30567. private _depthMask;
  30568. private _depthFunc;
  30569. private _cull;
  30570. private _cullFace;
  30571. private _zOffset;
  30572. private _frontFace;
  30573. /**
  30574. * Initializes the state.
  30575. */
  30576. constructor();
  30577. get isDirty(): boolean;
  30578. get zOffset(): number;
  30579. set zOffset(value: number);
  30580. get cullFace(): Nullable<number>;
  30581. set cullFace(value: Nullable<number>);
  30582. get cull(): Nullable<boolean>;
  30583. set cull(value: Nullable<boolean>);
  30584. get depthFunc(): Nullable<number>;
  30585. set depthFunc(value: Nullable<number>);
  30586. get depthMask(): boolean;
  30587. set depthMask(value: boolean);
  30588. get depthTest(): boolean;
  30589. set depthTest(value: boolean);
  30590. get frontFace(): Nullable<number>;
  30591. set frontFace(value: Nullable<number>);
  30592. reset(): void;
  30593. apply(gl: WebGLRenderingContext): void;
  30594. }
  30595. }
  30596. declare module BABYLON {
  30597. /**
  30598. * @hidden
  30599. **/
  30600. export class StencilState {
  30601. /** 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 */
  30602. static readonly ALWAYS: number;
  30603. /** Passed to stencilOperation to specify that stencil value must be kept */
  30604. static readonly KEEP: number;
  30605. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30606. static readonly REPLACE: number;
  30607. private _isStencilTestDirty;
  30608. private _isStencilMaskDirty;
  30609. private _isStencilFuncDirty;
  30610. private _isStencilOpDirty;
  30611. private _stencilTest;
  30612. private _stencilMask;
  30613. private _stencilFunc;
  30614. private _stencilFuncRef;
  30615. private _stencilFuncMask;
  30616. private _stencilOpStencilFail;
  30617. private _stencilOpDepthFail;
  30618. private _stencilOpStencilDepthPass;
  30619. get isDirty(): boolean;
  30620. get stencilFunc(): number;
  30621. set stencilFunc(value: number);
  30622. get stencilFuncRef(): number;
  30623. set stencilFuncRef(value: number);
  30624. get stencilFuncMask(): number;
  30625. set stencilFuncMask(value: number);
  30626. get stencilOpStencilFail(): number;
  30627. set stencilOpStencilFail(value: number);
  30628. get stencilOpDepthFail(): number;
  30629. set stencilOpDepthFail(value: number);
  30630. get stencilOpStencilDepthPass(): number;
  30631. set stencilOpStencilDepthPass(value: number);
  30632. get stencilMask(): number;
  30633. set stencilMask(value: number);
  30634. get stencilTest(): boolean;
  30635. set stencilTest(value: boolean);
  30636. constructor();
  30637. reset(): void;
  30638. apply(gl: WebGLRenderingContext): void;
  30639. }
  30640. }
  30641. declare module BABYLON {
  30642. /**
  30643. * @hidden
  30644. **/
  30645. export class AlphaState {
  30646. private _isAlphaBlendDirty;
  30647. private _isBlendFunctionParametersDirty;
  30648. private _isBlendEquationParametersDirty;
  30649. private _isBlendConstantsDirty;
  30650. private _alphaBlend;
  30651. private _blendFunctionParameters;
  30652. private _blendEquationParameters;
  30653. private _blendConstants;
  30654. /**
  30655. * Initializes the state.
  30656. */
  30657. constructor();
  30658. get isDirty(): boolean;
  30659. get alphaBlend(): boolean;
  30660. set alphaBlend(value: boolean);
  30661. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30662. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30663. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30664. reset(): void;
  30665. apply(gl: WebGLRenderingContext): void;
  30666. }
  30667. }
  30668. declare module BABYLON {
  30669. /** @hidden */
  30670. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30671. attributeProcessor(attribute: string): string;
  30672. varyingProcessor(varying: string, isFragment: boolean): string;
  30673. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30674. }
  30675. }
  30676. declare module BABYLON {
  30677. /**
  30678. * Interface for attribute information associated with buffer instanciation
  30679. */
  30680. export interface InstancingAttributeInfo {
  30681. /**
  30682. * Name of the GLSL attribute
  30683. * if attribute index is not specified, this is used to retrieve the index from the effect
  30684. */
  30685. attributeName: string;
  30686. /**
  30687. * Index/offset of the attribute in the vertex shader
  30688. * if not specified, this will be computes from the name.
  30689. */
  30690. index?: number;
  30691. /**
  30692. * size of the attribute, 1, 2, 3 or 4
  30693. */
  30694. attributeSize: number;
  30695. /**
  30696. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30697. */
  30698. offset: number;
  30699. /**
  30700. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30701. * default to 1
  30702. */
  30703. divisor?: number;
  30704. /**
  30705. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30706. * default is FLOAT
  30707. */
  30708. attributeType?: number;
  30709. /**
  30710. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30711. */
  30712. normalized?: boolean;
  30713. }
  30714. }
  30715. declare module BABYLON {
  30716. interface ThinEngine {
  30717. /**
  30718. * Update a video texture
  30719. * @param texture defines the texture to update
  30720. * @param video defines the video element to use
  30721. * @param invertY defines if data must be stored with Y axis inverted
  30722. */
  30723. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30724. }
  30725. }
  30726. declare module BABYLON {
  30727. /**
  30728. * Settings for finer control over video usage
  30729. */
  30730. export interface VideoTextureSettings {
  30731. /**
  30732. * Applies `autoplay` to video, if specified
  30733. */
  30734. autoPlay?: boolean;
  30735. /**
  30736. * Applies `loop` to video, if specified
  30737. */
  30738. loop?: boolean;
  30739. /**
  30740. * Automatically updates internal texture from video at every frame in the render loop
  30741. */
  30742. autoUpdateTexture: boolean;
  30743. /**
  30744. * Image src displayed during the video loading or until the user interacts with the video.
  30745. */
  30746. poster?: string;
  30747. }
  30748. /**
  30749. * If you want to display a video in your scene, this is the special texture for that.
  30750. * This special texture works similar to other textures, with the exception of a few parameters.
  30751. * @see https://doc.babylonjs.com/how_to/video_texture
  30752. */
  30753. export class VideoTexture extends Texture {
  30754. /**
  30755. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30756. */
  30757. readonly autoUpdateTexture: boolean;
  30758. /**
  30759. * The video instance used by the texture internally
  30760. */
  30761. readonly video: HTMLVideoElement;
  30762. private _onUserActionRequestedObservable;
  30763. /**
  30764. * Event triggerd when a dom action is required by the user to play the video.
  30765. * This happens due to recent changes in browser policies preventing video to auto start.
  30766. */
  30767. get onUserActionRequestedObservable(): Observable<Texture>;
  30768. private _generateMipMaps;
  30769. private _engine;
  30770. private _stillImageCaptured;
  30771. private _displayingPosterTexture;
  30772. private _settings;
  30773. private _createInternalTextureOnEvent;
  30774. private _frameId;
  30775. private _currentSrc;
  30776. /**
  30777. * Creates a video texture.
  30778. * If you want to display a video in your scene, this is the special texture for that.
  30779. * This special texture works similar to other textures, with the exception of a few parameters.
  30780. * @see https://doc.babylonjs.com/how_to/video_texture
  30781. * @param name optional name, will detect from video source, if not defined
  30782. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30783. * @param scene is obviously the current scene.
  30784. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30785. * @param invertY is false by default but can be used to invert video on Y axis
  30786. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30787. * @param settings allows finer control over video usage
  30788. */
  30789. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30790. private _getName;
  30791. private _getVideo;
  30792. private _createInternalTexture;
  30793. private reset;
  30794. /**
  30795. * @hidden Internal method to initiate `update`.
  30796. */
  30797. _rebuild(): void;
  30798. /**
  30799. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30800. */
  30801. update(): void;
  30802. /**
  30803. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30804. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30805. */
  30806. updateTexture(isVisible: boolean): void;
  30807. protected _updateInternalTexture: () => void;
  30808. /**
  30809. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30810. * @param url New url.
  30811. */
  30812. updateURL(url: string): void;
  30813. /**
  30814. * Clones the texture.
  30815. * @returns the cloned texture
  30816. */
  30817. clone(): VideoTexture;
  30818. /**
  30819. * Dispose the texture and release its associated resources.
  30820. */
  30821. dispose(): void;
  30822. /**
  30823. * Creates a video texture straight from a stream.
  30824. * @param scene Define the scene the texture should be created in
  30825. * @param stream Define the stream the texture should be created from
  30826. * @returns The created video texture as a promise
  30827. */
  30828. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30829. /**
  30830. * Creates a video texture straight from your WebCam video feed.
  30831. * @param scene Define the scene the texture should be created in
  30832. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30833. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30834. * @returns The created video texture as a promise
  30835. */
  30836. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30837. minWidth: number;
  30838. maxWidth: number;
  30839. minHeight: number;
  30840. maxHeight: number;
  30841. deviceId: string;
  30842. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30843. /**
  30844. * Creates a video texture straight from your WebCam video feed.
  30845. * @param scene Define the scene the texture should be created in
  30846. * @param onReady Define a callback to triggered once the texture will be ready
  30847. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30848. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30849. */
  30850. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30851. minWidth: number;
  30852. maxWidth: number;
  30853. minHeight: number;
  30854. maxHeight: number;
  30855. deviceId: string;
  30856. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30857. }
  30858. }
  30859. declare module BABYLON {
  30860. /**
  30861. * Defines the interface used by objects working like Scene
  30862. * @hidden
  30863. */
  30864. interface ISceneLike {
  30865. _addPendingData(data: any): void;
  30866. _removePendingData(data: any): void;
  30867. offlineProvider: IOfflineProvider;
  30868. }
  30869. /** Interface defining initialization parameters for Engine class */
  30870. export interface EngineOptions extends WebGLContextAttributes {
  30871. /**
  30872. * Defines if the engine should no exceed a specified device ratio
  30873. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30874. */
  30875. limitDeviceRatio?: number;
  30876. /**
  30877. * Defines if webvr should be enabled automatically
  30878. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30879. */
  30880. autoEnableWebVR?: boolean;
  30881. /**
  30882. * Defines if webgl2 should be turned off even if supported
  30883. * @see http://doc.babylonjs.com/features/webgl2
  30884. */
  30885. disableWebGL2Support?: boolean;
  30886. /**
  30887. * Defines if webaudio should be initialized as well
  30888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30889. */
  30890. audioEngine?: boolean;
  30891. /**
  30892. * Defines if animations should run using a deterministic lock step
  30893. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30894. */
  30895. deterministicLockstep?: boolean;
  30896. /** Defines the maximum steps to use with deterministic lock step mode */
  30897. lockstepMaxSteps?: number;
  30898. /** Defines the seconds between each deterministic lock step */
  30899. timeStep?: number;
  30900. /**
  30901. * Defines that engine should ignore context lost events
  30902. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30903. */
  30904. doNotHandleContextLost?: boolean;
  30905. /**
  30906. * Defines that engine should ignore modifying touch action attribute and style
  30907. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30908. */
  30909. doNotHandleTouchAction?: boolean;
  30910. /**
  30911. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30912. */
  30913. useHighPrecisionFloats?: boolean;
  30914. }
  30915. /**
  30916. * The base engine class (root of all engines)
  30917. */
  30918. export class ThinEngine {
  30919. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30920. static ExceptionList: ({
  30921. key: string;
  30922. capture: string;
  30923. captureConstraint: number;
  30924. targets: string[];
  30925. } | {
  30926. key: string;
  30927. capture: null;
  30928. captureConstraint: null;
  30929. targets: string[];
  30930. })[];
  30931. /** @hidden */
  30932. static _TextureLoaders: IInternalTextureLoader[];
  30933. /**
  30934. * Returns the current npm package of the sdk
  30935. */
  30936. static get NpmPackage(): string;
  30937. /**
  30938. * Returns the current version of the framework
  30939. */
  30940. static get Version(): string;
  30941. /**
  30942. * Returns a string describing the current engine
  30943. */
  30944. get description(): string;
  30945. /**
  30946. * Gets or sets the epsilon value used by collision engine
  30947. */
  30948. static CollisionsEpsilon: number;
  30949. /**
  30950. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30951. */
  30952. static get ShadersRepository(): string;
  30953. static set ShadersRepository(value: string);
  30954. /**
  30955. * Gets or sets the textures that the engine should not attempt to load as compressed
  30956. */
  30957. protected _excludedCompressedTextures: string[];
  30958. /**
  30959. * Filters the compressed texture formats to only include
  30960. * files that are not included in the skippable list
  30961. *
  30962. * @param url the current extension
  30963. * @param textureFormatInUse the current compressed texture format
  30964. * @returns "format" string
  30965. */
  30966. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30967. /** @hidden */
  30968. _shaderProcessor: IShaderProcessor;
  30969. /**
  30970. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30971. */
  30972. forcePOTTextures: boolean;
  30973. /**
  30974. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30975. */
  30976. isFullscreen: boolean;
  30977. /**
  30978. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30979. */
  30980. cullBackFaces: boolean;
  30981. /**
  30982. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30983. */
  30984. renderEvenInBackground: boolean;
  30985. /**
  30986. * Gets or sets a boolean indicating that cache can be kept between frames
  30987. */
  30988. preventCacheWipeBetweenFrames: boolean;
  30989. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30990. validateShaderPrograms: boolean;
  30991. /**
  30992. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30993. * This can provide greater z depth for distant objects.
  30994. */
  30995. useReverseDepthBuffer: boolean;
  30996. /**
  30997. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30998. */
  30999. disableUniformBuffers: boolean;
  31000. /** @hidden */
  31001. _uniformBuffers: UniformBuffer[];
  31002. /**
  31003. * Gets a boolean indicating that the engine supports uniform buffers
  31004. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31005. */
  31006. get supportsUniformBuffers(): boolean;
  31007. /** @hidden */
  31008. _gl: WebGLRenderingContext;
  31009. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31010. protected _windowIsBackground: boolean;
  31011. protected _webGLVersion: number;
  31012. protected _creationOptions: EngineOptions;
  31013. protected _highPrecisionShadersAllowed: boolean;
  31014. /** @hidden */
  31015. get _shouldUseHighPrecisionShader(): boolean;
  31016. /**
  31017. * Gets a boolean indicating that only power of 2 textures are supported
  31018. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31019. */
  31020. get needPOTTextures(): boolean;
  31021. /** @hidden */
  31022. _badOS: boolean;
  31023. /** @hidden */
  31024. _badDesktopOS: boolean;
  31025. private _hardwareScalingLevel;
  31026. /** @hidden */
  31027. _caps: EngineCapabilities;
  31028. private _isStencilEnable;
  31029. private _glVersion;
  31030. private _glRenderer;
  31031. private _glVendor;
  31032. /** @hidden */
  31033. _videoTextureSupported: boolean;
  31034. protected _renderingQueueLaunched: boolean;
  31035. protected _activeRenderLoops: (() => void)[];
  31036. /**
  31037. * Observable signaled when a context lost event is raised
  31038. */
  31039. onContextLostObservable: Observable<ThinEngine>;
  31040. /**
  31041. * Observable signaled when a context restored event is raised
  31042. */
  31043. onContextRestoredObservable: Observable<ThinEngine>;
  31044. private _onContextLost;
  31045. private _onContextRestored;
  31046. protected _contextWasLost: boolean;
  31047. /** @hidden */
  31048. _doNotHandleContextLost: boolean;
  31049. /**
  31050. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31052. */
  31053. get doNotHandleContextLost(): boolean;
  31054. set doNotHandleContextLost(value: boolean);
  31055. /**
  31056. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31057. */
  31058. disableVertexArrayObjects: boolean;
  31059. /** @hidden */
  31060. protected _colorWrite: boolean;
  31061. /** @hidden */
  31062. protected _colorWriteChanged: boolean;
  31063. /** @hidden */
  31064. protected _depthCullingState: DepthCullingState;
  31065. /** @hidden */
  31066. protected _stencilState: StencilState;
  31067. /** @hidden */
  31068. _alphaState: AlphaState;
  31069. /** @hidden */
  31070. _alphaMode: number;
  31071. /** @hidden */
  31072. _alphaEquation: number;
  31073. /** @hidden */
  31074. _internalTexturesCache: InternalTexture[];
  31075. /** @hidden */
  31076. protected _activeChannel: number;
  31077. private _currentTextureChannel;
  31078. /** @hidden */
  31079. protected _boundTexturesCache: {
  31080. [key: string]: Nullable<InternalTexture>;
  31081. };
  31082. /** @hidden */
  31083. protected _currentEffect: Nullable<Effect>;
  31084. /** @hidden */
  31085. protected _currentProgram: Nullable<WebGLProgram>;
  31086. private _compiledEffects;
  31087. private _vertexAttribArraysEnabled;
  31088. /** @hidden */
  31089. protected _cachedViewport: Nullable<IViewportLike>;
  31090. private _cachedVertexArrayObject;
  31091. /** @hidden */
  31092. protected _cachedVertexBuffers: any;
  31093. /** @hidden */
  31094. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31095. /** @hidden */
  31096. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31097. /** @hidden */
  31098. _currentRenderTarget: Nullable<InternalTexture>;
  31099. private _uintIndicesCurrentlySet;
  31100. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31101. /** @hidden */
  31102. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31103. private _currentBufferPointers;
  31104. private _currentInstanceLocations;
  31105. private _currentInstanceBuffers;
  31106. private _textureUnits;
  31107. /** @hidden */
  31108. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31109. /** @hidden */
  31110. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31111. /** @hidden */
  31112. _boundRenderFunction: any;
  31113. private _vaoRecordInProgress;
  31114. private _mustWipeVertexAttributes;
  31115. private _emptyTexture;
  31116. private _emptyCubeTexture;
  31117. private _emptyTexture3D;
  31118. private _emptyTexture2DArray;
  31119. /** @hidden */
  31120. _frameHandler: number;
  31121. private _nextFreeTextureSlots;
  31122. private _maxSimultaneousTextures;
  31123. private _activeRequests;
  31124. protected _texturesSupported: string[];
  31125. /** @hidden */
  31126. _textureFormatInUse: Nullable<string>;
  31127. protected get _supportsHardwareTextureRescaling(): boolean;
  31128. /**
  31129. * Gets the list of texture formats supported
  31130. */
  31131. get texturesSupported(): Array<string>;
  31132. /**
  31133. * Gets the list of texture formats in use
  31134. */
  31135. get textureFormatInUse(): Nullable<string>;
  31136. /**
  31137. * Gets the current viewport
  31138. */
  31139. get currentViewport(): Nullable<IViewportLike>;
  31140. /**
  31141. * Gets the default empty texture
  31142. */
  31143. get emptyTexture(): InternalTexture;
  31144. /**
  31145. * Gets the default empty 3D texture
  31146. */
  31147. get emptyTexture3D(): InternalTexture;
  31148. /**
  31149. * Gets the default empty 2D array texture
  31150. */
  31151. get emptyTexture2DArray(): InternalTexture;
  31152. /**
  31153. * Gets the default empty cube texture
  31154. */
  31155. get emptyCubeTexture(): InternalTexture;
  31156. /**
  31157. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31158. */
  31159. readonly premultipliedAlpha: boolean;
  31160. /**
  31161. * Observable event triggered before each texture is initialized
  31162. */
  31163. onBeforeTextureInitObservable: Observable<Texture>;
  31164. /**
  31165. * Creates a new engine
  31166. * @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
  31167. * @param antialias defines enable antialiasing (default: false)
  31168. * @param options defines further options to be sent to the getContext() function
  31169. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31170. */
  31171. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31172. private _rebuildInternalTextures;
  31173. private _rebuildEffects;
  31174. /**
  31175. * Gets a boolean indicating if all created effects are ready
  31176. * @returns true if all effects are ready
  31177. */
  31178. areAllEffectsReady(): boolean;
  31179. protected _rebuildBuffers(): void;
  31180. private _initGLContext;
  31181. /**
  31182. * Gets version of the current webGL context
  31183. */
  31184. get webGLVersion(): number;
  31185. /**
  31186. * Gets a string idenfifying the name of the class
  31187. * @returns "Engine" string
  31188. */
  31189. getClassName(): string;
  31190. /**
  31191. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31192. */
  31193. get isStencilEnable(): boolean;
  31194. /** @hidden */
  31195. _prepareWorkingCanvas(): void;
  31196. /**
  31197. * Reset the texture cache to empty state
  31198. */
  31199. resetTextureCache(): void;
  31200. /**
  31201. * Gets an object containing information about the current webGL context
  31202. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31203. */
  31204. getGlInfo(): {
  31205. vendor: string;
  31206. renderer: string;
  31207. version: string;
  31208. };
  31209. /**
  31210. * Defines the hardware scaling level.
  31211. * By default the hardware scaling level is computed from the window device ratio.
  31212. * 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.
  31213. * @param level defines the level to use
  31214. */
  31215. setHardwareScalingLevel(level: number): void;
  31216. /**
  31217. * Gets the current hardware scaling level.
  31218. * By default the hardware scaling level is computed from the window device ratio.
  31219. * 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.
  31220. * @returns a number indicating the current hardware scaling level
  31221. */
  31222. getHardwareScalingLevel(): number;
  31223. /**
  31224. * Gets the list of loaded textures
  31225. * @returns an array containing all loaded textures
  31226. */
  31227. getLoadedTexturesCache(): InternalTexture[];
  31228. /**
  31229. * Gets the object containing all engine capabilities
  31230. * @returns the EngineCapabilities object
  31231. */
  31232. getCaps(): EngineCapabilities;
  31233. /**
  31234. * stop executing a render loop function and remove it from the execution array
  31235. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31236. */
  31237. stopRenderLoop(renderFunction?: () => void): void;
  31238. /** @hidden */
  31239. _renderLoop(): void;
  31240. /**
  31241. * Gets the HTML canvas attached with the current webGL context
  31242. * @returns a HTML canvas
  31243. */
  31244. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31245. /**
  31246. * Gets host window
  31247. * @returns the host window object
  31248. */
  31249. getHostWindow(): Nullable<Window>;
  31250. /**
  31251. * Gets the current render width
  31252. * @param useScreen defines if screen size must be used (or the current render target if any)
  31253. * @returns a number defining the current render width
  31254. */
  31255. getRenderWidth(useScreen?: boolean): number;
  31256. /**
  31257. * Gets the current render height
  31258. * @param useScreen defines if screen size must be used (or the current render target if any)
  31259. * @returns a number defining the current render height
  31260. */
  31261. getRenderHeight(useScreen?: boolean): number;
  31262. /**
  31263. * Can be used to override the current requestAnimationFrame requester.
  31264. * @hidden
  31265. */
  31266. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31267. /**
  31268. * Register and execute a render loop. The engine can have more than one render function
  31269. * @param renderFunction defines the function to continuously execute
  31270. */
  31271. runRenderLoop(renderFunction: () => void): void;
  31272. /**
  31273. * Clear the current render buffer or the current render target (if any is set up)
  31274. * @param color defines the color to use
  31275. * @param backBuffer defines if the back buffer must be cleared
  31276. * @param depth defines if the depth buffer must be cleared
  31277. * @param stencil defines if the stencil buffer must be cleared
  31278. */
  31279. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31280. private _viewportCached;
  31281. /** @hidden */
  31282. _viewport(x: number, y: number, width: number, height: number): void;
  31283. /**
  31284. * Set the WebGL's viewport
  31285. * @param viewport defines the viewport element to be used
  31286. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31287. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31288. */
  31289. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31290. /**
  31291. * Begin a new frame
  31292. */
  31293. beginFrame(): void;
  31294. /**
  31295. * Enf the current frame
  31296. */
  31297. endFrame(): void;
  31298. /**
  31299. * Resize the view according to the canvas' size
  31300. */
  31301. resize(): void;
  31302. /**
  31303. * Force a specific size of the canvas
  31304. * @param width defines the new canvas' width
  31305. * @param height defines the new canvas' height
  31306. */
  31307. setSize(width: number, height: number): void;
  31308. /**
  31309. * Binds the frame buffer to the specified texture.
  31310. * @param texture The texture to render to or null for the default canvas
  31311. * @param faceIndex The face of the texture to render to in case of cube texture
  31312. * @param requiredWidth The width of the target to render to
  31313. * @param requiredHeight The height of the target to render to
  31314. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31315. * @param lodLevel defines the lod level to bind to the frame buffer
  31316. * @param layer defines the 2d array index to bind to frame buffer to
  31317. */
  31318. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31319. /** @hidden */
  31320. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31321. /**
  31322. * Unbind the current render target texture from the webGL context
  31323. * @param texture defines the render target texture to unbind
  31324. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31325. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31326. */
  31327. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31328. /**
  31329. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31330. */
  31331. flushFramebuffer(): void;
  31332. /**
  31333. * Unbind the current render target and bind the default framebuffer
  31334. */
  31335. restoreDefaultFramebuffer(): void;
  31336. /** @hidden */
  31337. protected _resetVertexBufferBinding(): void;
  31338. /**
  31339. * Creates a vertex buffer
  31340. * @param data the data for the vertex buffer
  31341. * @returns the new WebGL static buffer
  31342. */
  31343. createVertexBuffer(data: DataArray): DataBuffer;
  31344. private _createVertexBuffer;
  31345. /**
  31346. * Creates a dynamic vertex buffer
  31347. * @param data the data for the dynamic vertex buffer
  31348. * @returns the new WebGL dynamic buffer
  31349. */
  31350. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31351. protected _resetIndexBufferBinding(): void;
  31352. /**
  31353. * Creates a new index buffer
  31354. * @param indices defines the content of the index buffer
  31355. * @param updatable defines if the index buffer must be updatable
  31356. * @returns a new webGL buffer
  31357. */
  31358. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31359. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31360. /**
  31361. * Bind a webGL buffer to the webGL context
  31362. * @param buffer defines the buffer to bind
  31363. */
  31364. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31365. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31366. private bindBuffer;
  31367. /**
  31368. * update the bound buffer with the given data
  31369. * @param data defines the data to update
  31370. */
  31371. updateArrayBuffer(data: Float32Array): void;
  31372. private _vertexAttribPointer;
  31373. /** @hidden */
  31374. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31375. private _bindVertexBuffersAttributes;
  31376. /**
  31377. * Records a vertex array object
  31378. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31379. * @param vertexBuffers defines the list of vertex buffers to store
  31380. * @param indexBuffer defines the index buffer to store
  31381. * @param effect defines the effect to store
  31382. * @returns the new vertex array object
  31383. */
  31384. recordVertexArrayObject(vertexBuffers: {
  31385. [key: string]: VertexBuffer;
  31386. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31387. /**
  31388. * Bind a specific vertex array object
  31389. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31390. * @param vertexArrayObject defines the vertex array object to bind
  31391. * @param indexBuffer defines the index buffer to bind
  31392. */
  31393. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31394. /**
  31395. * Bind webGl buffers directly to the webGL context
  31396. * @param vertexBuffer defines the vertex buffer to bind
  31397. * @param indexBuffer defines the index buffer to bind
  31398. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31399. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31400. * @param effect defines the effect associated with the vertex buffer
  31401. */
  31402. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31403. private _unbindVertexArrayObject;
  31404. /**
  31405. * Bind a list of vertex buffers to the webGL context
  31406. * @param vertexBuffers defines the list of vertex buffers to bind
  31407. * @param indexBuffer defines the index buffer to bind
  31408. * @param effect defines the effect associated with the vertex buffers
  31409. */
  31410. bindBuffers(vertexBuffers: {
  31411. [key: string]: Nullable<VertexBuffer>;
  31412. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31413. /**
  31414. * Unbind all instance attributes
  31415. */
  31416. unbindInstanceAttributes(): void;
  31417. /**
  31418. * Release and free the memory of a vertex array object
  31419. * @param vao defines the vertex array object to delete
  31420. */
  31421. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31422. /** @hidden */
  31423. _releaseBuffer(buffer: DataBuffer): boolean;
  31424. protected _deleteBuffer(buffer: DataBuffer): void;
  31425. /**
  31426. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31427. * @param instancesBuffer defines the webGL buffer to update and bind
  31428. * @param data defines the data to store in the buffer
  31429. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31430. */
  31431. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31432. /**
  31433. * Bind the content of a webGL buffer used with instantiation
  31434. * @param instancesBuffer defines the webGL buffer to bind
  31435. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31436. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31437. */
  31438. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31439. /**
  31440. * Disable the instance attribute corresponding to the name in parameter
  31441. * @param name defines the name of the attribute to disable
  31442. */
  31443. disableInstanceAttributeByName(name: string): void;
  31444. /**
  31445. * Disable the instance attribute corresponding to the location in parameter
  31446. * @param attributeLocation defines the attribute location of the attribute to disable
  31447. */
  31448. disableInstanceAttribute(attributeLocation: number): void;
  31449. /**
  31450. * Disable the attribute corresponding to the location in parameter
  31451. * @param attributeLocation defines the attribute location of the attribute to disable
  31452. */
  31453. disableAttributeByIndex(attributeLocation: number): void;
  31454. /**
  31455. * Send a draw order
  31456. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31457. * @param indexStart defines the starting index
  31458. * @param indexCount defines the number of index to draw
  31459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31460. */
  31461. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31462. /**
  31463. * Draw a list of points
  31464. * @param verticesStart defines the index of first vertex to draw
  31465. * @param verticesCount defines the count of vertices to draw
  31466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31467. */
  31468. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31469. /**
  31470. * Draw a list of unindexed primitives
  31471. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31472. * @param verticesStart defines the index of first vertex to draw
  31473. * @param verticesCount defines the count of vertices to draw
  31474. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31475. */
  31476. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31477. /**
  31478. * Draw a list of indexed primitives
  31479. * @param fillMode defines the primitive to use
  31480. * @param indexStart defines the starting index
  31481. * @param indexCount defines the number of index to draw
  31482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31483. */
  31484. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31485. /**
  31486. * Draw a list of unindexed primitives
  31487. * @param fillMode defines the primitive to use
  31488. * @param verticesStart defines the index of first vertex to draw
  31489. * @param verticesCount defines the count of vertices to draw
  31490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31491. */
  31492. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31493. private _drawMode;
  31494. /** @hidden */
  31495. protected _reportDrawCall(): void;
  31496. /** @hidden */
  31497. _releaseEffect(effect: Effect): void;
  31498. /** @hidden */
  31499. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31500. /**
  31501. * Create a new effect (used to store vertex/fragment shaders)
  31502. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31503. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31504. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31505. * @param samplers defines an array of string used to represent textures
  31506. * @param defines defines the string containing the defines to use to compile the shaders
  31507. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31508. * @param onCompiled defines a function to call when the effect creation is successful
  31509. * @param onError defines a function to call when the effect creation has failed
  31510. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31511. * @returns the new Effect
  31512. */
  31513. 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;
  31514. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31515. private _compileShader;
  31516. private _compileRawShader;
  31517. /**
  31518. * Directly creates a webGL program
  31519. * @param pipelineContext defines the pipeline context to attach to
  31520. * @param vertexCode defines the vertex shader code to use
  31521. * @param fragmentCode defines the fragment shader code to use
  31522. * @param context defines the webGL context to use (if not set, the current one will be used)
  31523. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31524. * @returns the new webGL program
  31525. */
  31526. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31527. /**
  31528. * Creates a webGL program
  31529. * @param pipelineContext defines the pipeline context to attach to
  31530. * @param vertexCode defines the vertex shader code to use
  31531. * @param fragmentCode defines the fragment shader code to use
  31532. * @param defines defines the string containing the defines to use to compile the shaders
  31533. * @param context defines the webGL context to use (if not set, the current one will be used)
  31534. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31535. * @returns the new webGL program
  31536. */
  31537. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31538. /**
  31539. * Creates a new pipeline context
  31540. * @returns the new pipeline
  31541. */
  31542. createPipelineContext(): IPipelineContext;
  31543. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31544. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31545. /** @hidden */
  31546. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31547. /** @hidden */
  31548. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31549. /** @hidden */
  31550. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31551. /**
  31552. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31553. * @param pipelineContext defines the pipeline context to use
  31554. * @param uniformsNames defines the list of uniform names
  31555. * @returns an array of webGL uniform locations
  31556. */
  31557. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31558. /**
  31559. * Gets the lsit of active attributes for a given webGL program
  31560. * @param pipelineContext defines the pipeline context to use
  31561. * @param attributesNames defines the list of attribute names to get
  31562. * @returns an array of indices indicating the offset of each attribute
  31563. */
  31564. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31565. /**
  31566. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31567. * @param effect defines the effect to activate
  31568. */
  31569. enableEffect(effect: Nullable<Effect>): void;
  31570. /**
  31571. * Set the value of an uniform to a number (int)
  31572. * @param uniform defines the webGL uniform location where to store the value
  31573. * @param value defines the int number to store
  31574. */
  31575. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31576. /**
  31577. * Set the value of an uniform to an array of int32
  31578. * @param uniform defines the webGL uniform location where to store the value
  31579. * @param array defines the array of int32 to store
  31580. */
  31581. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31582. /**
  31583. * Set the value of an uniform to an array of int32 (stored as vec2)
  31584. * @param uniform defines the webGL uniform location where to store the value
  31585. * @param array defines the array of int32 to store
  31586. */
  31587. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31588. /**
  31589. * Set the value of an uniform to an array of int32 (stored as vec3)
  31590. * @param uniform defines the webGL uniform location where to store the value
  31591. * @param array defines the array of int32 to store
  31592. */
  31593. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31594. /**
  31595. * Set the value of an uniform to an array of int32 (stored as vec4)
  31596. * @param uniform defines the webGL uniform location where to store the value
  31597. * @param array defines the array of int32 to store
  31598. */
  31599. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31600. /**
  31601. * Set the value of an uniform to an array of number
  31602. * @param uniform defines the webGL uniform location where to store the value
  31603. * @param array defines the array of number to store
  31604. */
  31605. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31606. /**
  31607. * Set the value of an uniform to an array of number (stored as vec2)
  31608. * @param uniform defines the webGL uniform location where to store the value
  31609. * @param array defines the array of number to store
  31610. */
  31611. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31612. /**
  31613. * Set the value of an uniform to an array of number (stored as vec3)
  31614. * @param uniform defines the webGL uniform location where to store the value
  31615. * @param array defines the array of number to store
  31616. */
  31617. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31618. /**
  31619. * Set the value of an uniform to an array of number (stored as vec4)
  31620. * @param uniform defines the webGL uniform location where to store the value
  31621. * @param array defines the array of number to store
  31622. */
  31623. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31624. /**
  31625. * Set the value of an uniform to an array of float32 (stored as matrices)
  31626. * @param uniform defines the webGL uniform location where to store the value
  31627. * @param matrices defines the array of float32 to store
  31628. */
  31629. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31630. /**
  31631. * Set the value of an uniform to a matrix (3x3)
  31632. * @param uniform defines the webGL uniform location where to store the value
  31633. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31634. */
  31635. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31636. /**
  31637. * Set the value of an uniform to a matrix (2x2)
  31638. * @param uniform defines the webGL uniform location where to store the value
  31639. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31640. */
  31641. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31642. /**
  31643. * Set the value of an uniform to a number (float)
  31644. * @param uniform defines the webGL uniform location where to store the value
  31645. * @param value defines the float number to store
  31646. */
  31647. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31648. /**
  31649. * Set the value of an uniform to a vec2
  31650. * @param uniform defines the webGL uniform location where to store the value
  31651. * @param x defines the 1st component of the value
  31652. * @param y defines the 2nd component of the value
  31653. */
  31654. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31655. /**
  31656. * Set the value of an uniform to a vec3
  31657. * @param uniform defines the webGL uniform location where to store the value
  31658. * @param x defines the 1st component of the value
  31659. * @param y defines the 2nd component of the value
  31660. * @param z defines the 3rd component of the value
  31661. */
  31662. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31663. /**
  31664. * Set the value of an uniform to a vec4
  31665. * @param uniform defines the webGL uniform location where to store the value
  31666. * @param x defines the 1st component of the value
  31667. * @param y defines the 2nd component of the value
  31668. * @param z defines the 3rd component of the value
  31669. * @param w defines the 4th component of the value
  31670. */
  31671. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31672. /**
  31673. * Apply all cached states (depth, culling, stencil and alpha)
  31674. */
  31675. applyStates(): void;
  31676. /**
  31677. * Enable or disable color writing
  31678. * @param enable defines the state to set
  31679. */
  31680. setColorWrite(enable: boolean): void;
  31681. /**
  31682. * Gets a boolean indicating if color writing is enabled
  31683. * @returns the current color writing state
  31684. */
  31685. getColorWrite(): boolean;
  31686. /**
  31687. * Gets the depth culling state manager
  31688. */
  31689. get depthCullingState(): DepthCullingState;
  31690. /**
  31691. * Gets the alpha state manager
  31692. */
  31693. get alphaState(): AlphaState;
  31694. /**
  31695. * Gets the stencil state manager
  31696. */
  31697. get stencilState(): StencilState;
  31698. /**
  31699. * Clears the list of texture accessible through engine.
  31700. * This can help preventing texture load conflict due to name collision.
  31701. */
  31702. clearInternalTexturesCache(): void;
  31703. /**
  31704. * Force the entire cache to be cleared
  31705. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31706. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31707. */
  31708. wipeCaches(bruteForce?: boolean): void;
  31709. /** @hidden */
  31710. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31711. min: number;
  31712. mag: number;
  31713. };
  31714. /** @hidden */
  31715. _createTexture(): WebGLTexture;
  31716. /**
  31717. * Usually called from Texture.ts.
  31718. * Passed information to create a WebGLTexture
  31719. * @param urlArg defines a value which contains one of the following:
  31720. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31721. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31722. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31723. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31724. * @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)
  31725. * @param scene needed for loading to the correct scene
  31726. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31727. * @param onLoad optional callback to be called upon successful completion
  31728. * @param onError optional callback to be called upon failure
  31729. * @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
  31730. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31731. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31732. * @param forcedExtension defines the extension to use to pick the right loader
  31733. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31734. * @param mimeType defines an optional mime type
  31735. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31736. */
  31737. 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;
  31738. /**
  31739. * Loads an image as an HTMLImageElement.
  31740. * @param input url string, ArrayBuffer, or Blob to load
  31741. * @param onLoad callback called when the image successfully loads
  31742. * @param onError callback called when the image fails to load
  31743. * @param offlineProvider offline provider for caching
  31744. * @param mimeType optional mime type
  31745. * @returns the HTMLImageElement of the loaded image
  31746. * @hidden
  31747. */
  31748. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  31749. /**
  31750. * @hidden
  31751. */
  31752. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31753. /**
  31754. * Creates a raw texture
  31755. * @param data defines the data to store in the texture
  31756. * @param width defines the width of the texture
  31757. * @param height defines the height of the texture
  31758. * @param format defines the format of the data
  31759. * @param generateMipMaps defines if the engine should generate the mip levels
  31760. * @param invertY defines if data must be stored with Y axis inverted
  31761. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31762. * @param compression defines the compression used (null by default)
  31763. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31764. * @returns the raw texture inside an InternalTexture
  31765. */
  31766. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31767. /**
  31768. * Creates a new raw cube texture
  31769. * @param data defines the array of data to use to create each face
  31770. * @param size defines the size of the textures
  31771. * @param format defines the format of the data
  31772. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31773. * @param generateMipMaps defines if the engine should generate the mip levels
  31774. * @param invertY defines if data must be stored with Y axis inverted
  31775. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31776. * @param compression defines the compression used (null by default)
  31777. * @returns the cube texture as an InternalTexture
  31778. */
  31779. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31780. /**
  31781. * Creates a new raw 3D texture
  31782. * @param data defines the data used to create the texture
  31783. * @param width defines the width of the texture
  31784. * @param height defines the height of the texture
  31785. * @param depth defines the depth of the texture
  31786. * @param format defines the format of the texture
  31787. * @param generateMipMaps defines if the engine must generate mip levels
  31788. * @param invertY defines if data must be stored with Y axis inverted
  31789. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31790. * @param compression defines the compressed used (can be null)
  31791. * @param textureType defines the compressed used (can be null)
  31792. * @returns a new raw 3D texture (stored in an InternalTexture)
  31793. */
  31794. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31795. /**
  31796. * Creates a new raw 2D array texture
  31797. * @param data defines the data used to create the texture
  31798. * @param width defines the width of the texture
  31799. * @param height defines the height of the texture
  31800. * @param depth defines the number of layers of the texture
  31801. * @param format defines the format of the texture
  31802. * @param generateMipMaps defines if the engine must generate mip levels
  31803. * @param invertY defines if data must be stored with Y axis inverted
  31804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31805. * @param compression defines the compressed used (can be null)
  31806. * @param textureType defines the compressed used (can be null)
  31807. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31808. */
  31809. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31810. private _unpackFlipYCached;
  31811. /**
  31812. * In case you are sharing the context with other applications, it might
  31813. * be interested to not cache the unpack flip y state to ensure a consistent
  31814. * value would be set.
  31815. */
  31816. enableUnpackFlipYCached: boolean;
  31817. /** @hidden */
  31818. _unpackFlipY(value: boolean): void;
  31819. /** @hidden */
  31820. _getUnpackAlignement(): number;
  31821. private _getTextureTarget;
  31822. /**
  31823. * Update the sampling mode of a given texture
  31824. * @param samplingMode defines the required sampling mode
  31825. * @param texture defines the texture to update
  31826. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31827. */
  31828. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31829. /**
  31830. * Update the sampling mode of a given texture
  31831. * @param texture defines the texture to update
  31832. * @param wrapU defines the texture wrap mode of the u coordinates
  31833. * @param wrapV defines the texture wrap mode of the v coordinates
  31834. * @param wrapR defines the texture wrap mode of the r coordinates
  31835. */
  31836. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31837. /** @hidden */
  31838. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31839. width: number;
  31840. height: number;
  31841. layers?: number;
  31842. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31843. /** @hidden */
  31844. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31845. /** @hidden */
  31846. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31847. /**
  31848. * Update a portion of an internal texture
  31849. * @param texture defines the texture to update
  31850. * @param imageData defines the data to store into the texture
  31851. * @param xOffset defines the x coordinates of the update rectangle
  31852. * @param yOffset defines the y coordinates of the update rectangle
  31853. * @param width defines the width of the update rectangle
  31854. * @param height defines the height of the update rectangle
  31855. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31856. * @param lod defines the lod level to update (0 by default)
  31857. */
  31858. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31859. /** @hidden */
  31860. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31861. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31862. private _prepareWebGLTexture;
  31863. /** @hidden */
  31864. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31865. private _getDepthStencilBuffer;
  31866. /** @hidden */
  31867. _releaseFramebufferObjects(texture: InternalTexture): void;
  31868. /** @hidden */
  31869. _releaseTexture(texture: InternalTexture): void;
  31870. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31871. protected _setProgram(program: WebGLProgram): void;
  31872. protected _boundUniforms: {
  31873. [key: number]: WebGLUniformLocation;
  31874. };
  31875. /**
  31876. * Binds an effect to the webGL context
  31877. * @param effect defines the effect to bind
  31878. */
  31879. bindSamplers(effect: Effect): void;
  31880. private _activateCurrentTexture;
  31881. /** @hidden */
  31882. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31883. /** @hidden */
  31884. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31885. /**
  31886. * Unbind all textures from the webGL context
  31887. */
  31888. unbindAllTextures(): void;
  31889. /**
  31890. * Sets a texture to the according uniform.
  31891. * @param channel The texture channel
  31892. * @param uniform The uniform to set
  31893. * @param texture The texture to apply
  31894. */
  31895. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31896. private _bindSamplerUniformToChannel;
  31897. private _getTextureWrapMode;
  31898. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31899. /**
  31900. * Sets an array of texture to the webGL context
  31901. * @param channel defines the channel where the texture array must be set
  31902. * @param uniform defines the associated uniform location
  31903. * @param textures defines the array of textures to bind
  31904. */
  31905. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31906. /** @hidden */
  31907. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31908. private _setTextureParameterFloat;
  31909. private _setTextureParameterInteger;
  31910. /**
  31911. * Unbind all vertex attributes from the webGL context
  31912. */
  31913. unbindAllAttributes(): void;
  31914. /**
  31915. * 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
  31916. */
  31917. releaseEffects(): void;
  31918. /**
  31919. * Dispose and release all associated resources
  31920. */
  31921. dispose(): void;
  31922. /**
  31923. * Attach a new callback raised when context lost event is fired
  31924. * @param callback defines the callback to call
  31925. */
  31926. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31927. /**
  31928. * Attach a new callback raised when context restored event is fired
  31929. * @param callback defines the callback to call
  31930. */
  31931. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31932. /**
  31933. * Get the current error code of the webGL context
  31934. * @returns the error code
  31935. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31936. */
  31937. getError(): number;
  31938. private _canRenderToFloatFramebuffer;
  31939. private _canRenderToHalfFloatFramebuffer;
  31940. private _canRenderToFramebuffer;
  31941. /** @hidden */
  31942. _getWebGLTextureType(type: number): number;
  31943. /** @hidden */
  31944. _getInternalFormat(format: number): number;
  31945. /** @hidden */
  31946. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31947. /** @hidden */
  31948. _getRGBAMultiSampleBufferFormat(type: number): number;
  31949. /** @hidden */
  31950. _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;
  31951. /**
  31952. * Loads a file from a url
  31953. * @param url url to load
  31954. * @param onSuccess callback called when the file successfully loads
  31955. * @param onProgress callback called while file is loading (if the server supports this mode)
  31956. * @param offlineProvider defines the offline provider for caching
  31957. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31958. * @param onError callback called when the file fails to load
  31959. * @returns a file request object
  31960. * @hidden
  31961. */
  31962. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  31963. /**
  31964. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31965. * @param x defines the x coordinate of the rectangle where pixels must be read
  31966. * @param y defines the y coordinate of the rectangle where pixels must be read
  31967. * @param width defines the width of the rectangle where pixels must be read
  31968. * @param height defines the height of the rectangle where pixels must be read
  31969. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31970. * @returns a Uint8Array containing RGBA colors
  31971. */
  31972. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31973. private static _isSupported;
  31974. /**
  31975. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31976. * @returns true if the engine can be created
  31977. * @ignorenaming
  31978. */
  31979. static isSupported(): boolean;
  31980. /**
  31981. * Find the next highest power of two.
  31982. * @param x Number to start search from.
  31983. * @return Next highest power of two.
  31984. */
  31985. static CeilingPOT(x: number): number;
  31986. /**
  31987. * Find the next lowest power of two.
  31988. * @param x Number to start search from.
  31989. * @return Next lowest power of two.
  31990. */
  31991. static FloorPOT(x: number): number;
  31992. /**
  31993. * Find the nearest power of two.
  31994. * @param x Number to start search from.
  31995. * @return Next nearest power of two.
  31996. */
  31997. static NearestPOT(x: number): number;
  31998. /**
  31999. * Get the closest exponent of two
  32000. * @param value defines the value to approximate
  32001. * @param max defines the maximum value to return
  32002. * @param mode defines how to define the closest value
  32003. * @returns closest exponent of two of the given value
  32004. */
  32005. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32006. /**
  32007. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32008. * @param func - the function to be called
  32009. * @param requester - the object that will request the next frame. Falls back to window.
  32010. * @returns frame number
  32011. */
  32012. static QueueNewFrame(func: () => void, requester?: any): number;
  32013. /**
  32014. * Gets host document
  32015. * @returns the host document object
  32016. */
  32017. getHostDocument(): Nullable<Document>;
  32018. }
  32019. }
  32020. declare module BABYLON {
  32021. /**
  32022. * Class representing spherical harmonics coefficients to the 3rd degree
  32023. */
  32024. export class SphericalHarmonics {
  32025. /**
  32026. * Defines whether or not the harmonics have been prescaled for rendering.
  32027. */
  32028. preScaled: boolean;
  32029. /**
  32030. * The l0,0 coefficients of the spherical harmonics
  32031. */
  32032. l00: Vector3;
  32033. /**
  32034. * The l1,-1 coefficients of the spherical harmonics
  32035. */
  32036. l1_1: Vector3;
  32037. /**
  32038. * The l1,0 coefficients of the spherical harmonics
  32039. */
  32040. l10: Vector3;
  32041. /**
  32042. * The l1,1 coefficients of the spherical harmonics
  32043. */
  32044. l11: Vector3;
  32045. /**
  32046. * The l2,-2 coefficients of the spherical harmonics
  32047. */
  32048. l2_2: Vector3;
  32049. /**
  32050. * The l2,-1 coefficients of the spherical harmonics
  32051. */
  32052. l2_1: Vector3;
  32053. /**
  32054. * The l2,0 coefficients of the spherical harmonics
  32055. */
  32056. l20: Vector3;
  32057. /**
  32058. * The l2,1 coefficients of the spherical harmonics
  32059. */
  32060. l21: Vector3;
  32061. /**
  32062. * The l2,2 coefficients of the spherical harmonics
  32063. */
  32064. l22: Vector3;
  32065. /**
  32066. * Adds a light to the spherical harmonics
  32067. * @param direction the direction of the light
  32068. * @param color the color of the light
  32069. * @param deltaSolidAngle the delta solid angle of the light
  32070. */
  32071. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32072. /**
  32073. * Scales the spherical harmonics by the given amount
  32074. * @param scale the amount to scale
  32075. */
  32076. scaleInPlace(scale: number): void;
  32077. /**
  32078. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32079. *
  32080. * ```
  32081. * E_lm = A_l * L_lm
  32082. * ```
  32083. *
  32084. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32085. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32086. * the scaling factors are given in equation 9.
  32087. */
  32088. convertIncidentRadianceToIrradiance(): void;
  32089. /**
  32090. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32091. *
  32092. * ```
  32093. * L = (1/pi) * E * rho
  32094. * ```
  32095. *
  32096. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32097. */
  32098. convertIrradianceToLambertianRadiance(): void;
  32099. /**
  32100. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32101. * required operations at run time.
  32102. *
  32103. * This is simply done by scaling back the SH with Ylm constants parameter.
  32104. * The trigonometric part being applied by the shader at run time.
  32105. */
  32106. preScaleForRendering(): void;
  32107. /**
  32108. * Constructs a spherical harmonics from an array.
  32109. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32110. * @returns the spherical harmonics
  32111. */
  32112. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32113. /**
  32114. * Gets the spherical harmonics from polynomial
  32115. * @param polynomial the spherical polynomial
  32116. * @returns the spherical harmonics
  32117. */
  32118. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32119. }
  32120. /**
  32121. * Class representing spherical polynomial coefficients to the 3rd degree
  32122. */
  32123. export class SphericalPolynomial {
  32124. private _harmonics;
  32125. /**
  32126. * The spherical harmonics used to create the polynomials.
  32127. */
  32128. get preScaledHarmonics(): SphericalHarmonics;
  32129. /**
  32130. * The x coefficients of the spherical polynomial
  32131. */
  32132. x: Vector3;
  32133. /**
  32134. * The y coefficients of the spherical polynomial
  32135. */
  32136. y: Vector3;
  32137. /**
  32138. * The z coefficients of the spherical polynomial
  32139. */
  32140. z: Vector3;
  32141. /**
  32142. * The xx coefficients of the spherical polynomial
  32143. */
  32144. xx: Vector3;
  32145. /**
  32146. * The yy coefficients of the spherical polynomial
  32147. */
  32148. yy: Vector3;
  32149. /**
  32150. * The zz coefficients of the spherical polynomial
  32151. */
  32152. zz: Vector3;
  32153. /**
  32154. * The xy coefficients of the spherical polynomial
  32155. */
  32156. xy: Vector3;
  32157. /**
  32158. * The yz coefficients of the spherical polynomial
  32159. */
  32160. yz: Vector3;
  32161. /**
  32162. * The zx coefficients of the spherical polynomial
  32163. */
  32164. zx: Vector3;
  32165. /**
  32166. * Adds an ambient color to the spherical polynomial
  32167. * @param color the color to add
  32168. */
  32169. addAmbient(color: Color3): void;
  32170. /**
  32171. * Scales the spherical polynomial by the given amount
  32172. * @param scale the amount to scale
  32173. */
  32174. scaleInPlace(scale: number): void;
  32175. /**
  32176. * Gets the spherical polynomial from harmonics
  32177. * @param harmonics the spherical harmonics
  32178. * @returns the spherical polynomial
  32179. */
  32180. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32181. /**
  32182. * Constructs a spherical polynomial from an array.
  32183. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32184. * @returns the spherical polynomial
  32185. */
  32186. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32187. }
  32188. }
  32189. declare module BABYLON {
  32190. /**
  32191. * Defines the source of the internal texture
  32192. */
  32193. export enum InternalTextureSource {
  32194. /**
  32195. * The source of the texture data is unknown
  32196. */
  32197. Unknown = 0,
  32198. /**
  32199. * Texture data comes from an URL
  32200. */
  32201. Url = 1,
  32202. /**
  32203. * Texture data is only used for temporary storage
  32204. */
  32205. Temp = 2,
  32206. /**
  32207. * Texture data comes from raw data (ArrayBuffer)
  32208. */
  32209. Raw = 3,
  32210. /**
  32211. * Texture content is dynamic (video or dynamic texture)
  32212. */
  32213. Dynamic = 4,
  32214. /**
  32215. * Texture content is generated by rendering to it
  32216. */
  32217. RenderTarget = 5,
  32218. /**
  32219. * Texture content is part of a multi render target process
  32220. */
  32221. MultiRenderTarget = 6,
  32222. /**
  32223. * Texture data comes from a cube data file
  32224. */
  32225. Cube = 7,
  32226. /**
  32227. * Texture data comes from a raw cube data
  32228. */
  32229. CubeRaw = 8,
  32230. /**
  32231. * Texture data come from a prefiltered cube data file
  32232. */
  32233. CubePrefiltered = 9,
  32234. /**
  32235. * Texture content is raw 3D data
  32236. */
  32237. Raw3D = 10,
  32238. /**
  32239. * Texture content is raw 2D array data
  32240. */
  32241. Raw2DArray = 11,
  32242. /**
  32243. * Texture content is a depth texture
  32244. */
  32245. Depth = 12,
  32246. /**
  32247. * Texture data comes from a raw cube data encoded with RGBD
  32248. */
  32249. CubeRawRGBD = 13
  32250. }
  32251. /**
  32252. * Class used to store data associated with WebGL texture data for the engine
  32253. * This class should not be used directly
  32254. */
  32255. export class InternalTexture {
  32256. /** @hidden */
  32257. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32258. /**
  32259. * Defines if the texture is ready
  32260. */
  32261. isReady: boolean;
  32262. /**
  32263. * Defines if the texture is a cube texture
  32264. */
  32265. isCube: boolean;
  32266. /**
  32267. * Defines if the texture contains 3D data
  32268. */
  32269. is3D: boolean;
  32270. /**
  32271. * Defines if the texture contains 2D array data
  32272. */
  32273. is2DArray: boolean;
  32274. /**
  32275. * Defines if the texture contains multiview data
  32276. */
  32277. isMultiview: boolean;
  32278. /**
  32279. * Gets the URL used to load this texture
  32280. */
  32281. url: string;
  32282. /**
  32283. * Gets the sampling mode of the texture
  32284. */
  32285. samplingMode: number;
  32286. /**
  32287. * Gets a boolean indicating if the texture needs mipmaps generation
  32288. */
  32289. generateMipMaps: boolean;
  32290. /**
  32291. * Gets the number of samples used by the texture (WebGL2+ only)
  32292. */
  32293. samples: number;
  32294. /**
  32295. * Gets the type of the texture (int, float...)
  32296. */
  32297. type: number;
  32298. /**
  32299. * Gets the format of the texture (RGB, RGBA...)
  32300. */
  32301. format: number;
  32302. /**
  32303. * Observable called when the texture is loaded
  32304. */
  32305. onLoadedObservable: Observable<InternalTexture>;
  32306. /**
  32307. * Gets the width of the texture
  32308. */
  32309. width: number;
  32310. /**
  32311. * Gets the height of the texture
  32312. */
  32313. height: number;
  32314. /**
  32315. * Gets the depth of the texture
  32316. */
  32317. depth: number;
  32318. /**
  32319. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32320. */
  32321. baseWidth: number;
  32322. /**
  32323. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32324. */
  32325. baseHeight: number;
  32326. /**
  32327. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32328. */
  32329. baseDepth: number;
  32330. /**
  32331. * Gets a boolean indicating if the texture is inverted on Y axis
  32332. */
  32333. invertY: boolean;
  32334. /** @hidden */
  32335. _invertVScale: boolean;
  32336. /** @hidden */
  32337. _associatedChannel: number;
  32338. /** @hidden */
  32339. _source: InternalTextureSource;
  32340. /** @hidden */
  32341. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32342. /** @hidden */
  32343. _bufferView: Nullable<ArrayBufferView>;
  32344. /** @hidden */
  32345. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32346. /** @hidden */
  32347. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32348. /** @hidden */
  32349. _size: number;
  32350. /** @hidden */
  32351. _extension: string;
  32352. /** @hidden */
  32353. _files: Nullable<string[]>;
  32354. /** @hidden */
  32355. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32356. /** @hidden */
  32357. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32358. /** @hidden */
  32359. _framebuffer: Nullable<WebGLFramebuffer>;
  32360. /** @hidden */
  32361. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32362. /** @hidden */
  32363. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32364. /** @hidden */
  32365. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32366. /** @hidden */
  32367. _attachments: Nullable<number[]>;
  32368. /** @hidden */
  32369. _cachedCoordinatesMode: Nullable<number>;
  32370. /** @hidden */
  32371. _cachedWrapU: Nullable<number>;
  32372. /** @hidden */
  32373. _cachedWrapV: Nullable<number>;
  32374. /** @hidden */
  32375. _cachedWrapR: Nullable<number>;
  32376. /** @hidden */
  32377. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32378. /** @hidden */
  32379. _isDisabled: boolean;
  32380. /** @hidden */
  32381. _compression: Nullable<string>;
  32382. /** @hidden */
  32383. _generateStencilBuffer: boolean;
  32384. /** @hidden */
  32385. _generateDepthBuffer: boolean;
  32386. /** @hidden */
  32387. _comparisonFunction: number;
  32388. /** @hidden */
  32389. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32390. /** @hidden */
  32391. _lodGenerationScale: number;
  32392. /** @hidden */
  32393. _lodGenerationOffset: number;
  32394. /** @hidden */
  32395. _depthStencilTexture: Nullable<InternalTexture>;
  32396. /** @hidden */
  32397. _colorTextureArray: Nullable<WebGLTexture>;
  32398. /** @hidden */
  32399. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32400. /** @hidden */
  32401. _lodTextureHigh: Nullable<BaseTexture>;
  32402. /** @hidden */
  32403. _lodTextureMid: Nullable<BaseTexture>;
  32404. /** @hidden */
  32405. _lodTextureLow: Nullable<BaseTexture>;
  32406. /** @hidden */
  32407. _isRGBD: boolean;
  32408. /** @hidden */
  32409. _linearSpecularLOD: boolean;
  32410. /** @hidden */
  32411. _irradianceTexture: Nullable<BaseTexture>;
  32412. /** @hidden */
  32413. _webGLTexture: Nullable<WebGLTexture>;
  32414. /** @hidden */
  32415. _references: number;
  32416. private _engine;
  32417. /**
  32418. * Gets the Engine the texture belongs to.
  32419. * @returns The babylon engine
  32420. */
  32421. getEngine(): ThinEngine;
  32422. /**
  32423. * Gets the data source type of the texture
  32424. */
  32425. get source(): InternalTextureSource;
  32426. /**
  32427. * Creates a new InternalTexture
  32428. * @param engine defines the engine to use
  32429. * @param source defines the type of data that will be used
  32430. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32431. */
  32432. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32433. /**
  32434. * Increments the number of references (ie. the number of Texture that point to it)
  32435. */
  32436. incrementReferences(): void;
  32437. /**
  32438. * Change the size of the texture (not the size of the content)
  32439. * @param width defines the new width
  32440. * @param height defines the new height
  32441. * @param depth defines the new depth (1 by default)
  32442. */
  32443. updateSize(width: int, height: int, depth?: int): void;
  32444. /** @hidden */
  32445. _rebuild(): void;
  32446. /** @hidden */
  32447. _swapAndDie(target: InternalTexture): void;
  32448. /**
  32449. * Dispose the current allocated resources
  32450. */
  32451. dispose(): void;
  32452. }
  32453. }
  32454. declare module BABYLON {
  32455. /**
  32456. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32457. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32458. */
  32459. export class Analyser {
  32460. /**
  32461. * Gets or sets the smoothing
  32462. * @ignorenaming
  32463. */
  32464. SMOOTHING: number;
  32465. /**
  32466. * Gets or sets the FFT table size
  32467. * @ignorenaming
  32468. */
  32469. FFT_SIZE: number;
  32470. /**
  32471. * Gets or sets the bar graph amplitude
  32472. * @ignorenaming
  32473. */
  32474. BARGRAPHAMPLITUDE: number;
  32475. /**
  32476. * Gets or sets the position of the debug canvas
  32477. * @ignorenaming
  32478. */
  32479. DEBUGCANVASPOS: {
  32480. x: number;
  32481. y: number;
  32482. };
  32483. /**
  32484. * Gets or sets the debug canvas size
  32485. * @ignorenaming
  32486. */
  32487. DEBUGCANVASSIZE: {
  32488. width: number;
  32489. height: number;
  32490. };
  32491. private _byteFreqs;
  32492. private _byteTime;
  32493. private _floatFreqs;
  32494. private _webAudioAnalyser;
  32495. private _debugCanvas;
  32496. private _debugCanvasContext;
  32497. private _scene;
  32498. private _registerFunc;
  32499. private _audioEngine;
  32500. /**
  32501. * Creates a new analyser
  32502. * @param scene defines hosting scene
  32503. */
  32504. constructor(scene: Scene);
  32505. /**
  32506. * Get the number of data values you will have to play with for the visualization
  32507. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32508. * @returns a number
  32509. */
  32510. getFrequencyBinCount(): number;
  32511. /**
  32512. * Gets the current frequency data as a byte array
  32513. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32514. * @returns a Uint8Array
  32515. */
  32516. getByteFrequencyData(): Uint8Array;
  32517. /**
  32518. * Gets the current waveform as a byte array
  32519. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32520. * @returns a Uint8Array
  32521. */
  32522. getByteTimeDomainData(): Uint8Array;
  32523. /**
  32524. * Gets the current frequency data as a float array
  32525. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32526. * @returns a Float32Array
  32527. */
  32528. getFloatFrequencyData(): Float32Array;
  32529. /**
  32530. * Renders the debug canvas
  32531. */
  32532. drawDebugCanvas(): void;
  32533. /**
  32534. * Stops rendering the debug canvas and removes it
  32535. */
  32536. stopDebugCanvas(): void;
  32537. /**
  32538. * Connects two audio nodes
  32539. * @param inputAudioNode defines first node to connect
  32540. * @param outputAudioNode defines second node to connect
  32541. */
  32542. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32543. /**
  32544. * Releases all associated resources
  32545. */
  32546. dispose(): void;
  32547. }
  32548. }
  32549. declare module BABYLON {
  32550. /**
  32551. * This represents an audio engine and it is responsible
  32552. * to play, synchronize and analyse sounds throughout the application.
  32553. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32554. */
  32555. export interface IAudioEngine extends IDisposable {
  32556. /**
  32557. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32558. */
  32559. readonly canUseWebAudio: boolean;
  32560. /**
  32561. * Gets the current AudioContext if available.
  32562. */
  32563. readonly audioContext: Nullable<AudioContext>;
  32564. /**
  32565. * The master gain node defines the global audio volume of your audio engine.
  32566. */
  32567. readonly masterGain: GainNode;
  32568. /**
  32569. * Gets whether or not mp3 are supported by your browser.
  32570. */
  32571. readonly isMP3supported: boolean;
  32572. /**
  32573. * Gets whether or not ogg are supported by your browser.
  32574. */
  32575. readonly isOGGsupported: boolean;
  32576. /**
  32577. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32578. * @ignoreNaming
  32579. */
  32580. WarnedWebAudioUnsupported: boolean;
  32581. /**
  32582. * Defines if the audio engine relies on a custom unlocked button.
  32583. * In this case, the embedded button will not be displayed.
  32584. */
  32585. useCustomUnlockedButton: boolean;
  32586. /**
  32587. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32588. */
  32589. readonly unlocked: boolean;
  32590. /**
  32591. * Event raised when audio has been unlocked on the browser.
  32592. */
  32593. onAudioUnlockedObservable: Observable<AudioEngine>;
  32594. /**
  32595. * Event raised when audio has been locked on the browser.
  32596. */
  32597. onAudioLockedObservable: Observable<AudioEngine>;
  32598. /**
  32599. * Flags the audio engine in Locked state.
  32600. * This happens due to new browser policies preventing audio to autoplay.
  32601. */
  32602. lock(): void;
  32603. /**
  32604. * Unlocks the audio engine once a user action has been done on the dom.
  32605. * This is helpful to resume play once browser policies have been satisfied.
  32606. */
  32607. unlock(): void;
  32608. }
  32609. /**
  32610. * This represents the default audio engine used in babylon.
  32611. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32612. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32613. */
  32614. export class AudioEngine implements IAudioEngine {
  32615. private _audioContext;
  32616. private _audioContextInitialized;
  32617. private _muteButton;
  32618. private _hostElement;
  32619. /**
  32620. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32621. */
  32622. canUseWebAudio: boolean;
  32623. /**
  32624. * The master gain node defines the global audio volume of your audio engine.
  32625. */
  32626. masterGain: GainNode;
  32627. /**
  32628. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32629. * @ignoreNaming
  32630. */
  32631. WarnedWebAudioUnsupported: boolean;
  32632. /**
  32633. * Gets whether or not mp3 are supported by your browser.
  32634. */
  32635. isMP3supported: boolean;
  32636. /**
  32637. * Gets whether or not ogg are supported by your browser.
  32638. */
  32639. isOGGsupported: boolean;
  32640. /**
  32641. * Gets whether audio has been unlocked on the device.
  32642. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32643. * a user interaction has happened.
  32644. */
  32645. unlocked: boolean;
  32646. /**
  32647. * Defines if the audio engine relies on a custom unlocked button.
  32648. * In this case, the embedded button will not be displayed.
  32649. */
  32650. useCustomUnlockedButton: boolean;
  32651. /**
  32652. * Event raised when audio has been unlocked on the browser.
  32653. */
  32654. onAudioUnlockedObservable: Observable<AudioEngine>;
  32655. /**
  32656. * Event raised when audio has been locked on the browser.
  32657. */
  32658. onAudioLockedObservable: Observable<AudioEngine>;
  32659. /**
  32660. * Gets the current AudioContext if available.
  32661. */
  32662. get audioContext(): Nullable<AudioContext>;
  32663. private _connectedAnalyser;
  32664. /**
  32665. * Instantiates a new audio engine.
  32666. *
  32667. * There should be only one per page as some browsers restrict the number
  32668. * of audio contexts you can create.
  32669. * @param hostElement defines the host element where to display the mute icon if necessary
  32670. */
  32671. constructor(hostElement?: Nullable<HTMLElement>);
  32672. /**
  32673. * Flags the audio engine in Locked state.
  32674. * This happens due to new browser policies preventing audio to autoplay.
  32675. */
  32676. lock(): void;
  32677. /**
  32678. * Unlocks the audio engine once a user action has been done on the dom.
  32679. * This is helpful to resume play once browser policies have been satisfied.
  32680. */
  32681. unlock(): void;
  32682. private _resumeAudioContext;
  32683. private _initializeAudioContext;
  32684. private _tryToRun;
  32685. private _triggerRunningState;
  32686. private _triggerSuspendedState;
  32687. private _displayMuteButton;
  32688. private _moveButtonToTopLeft;
  32689. private _onResize;
  32690. private _hideMuteButton;
  32691. /**
  32692. * Destroy and release the resources associated with the audio ccontext.
  32693. */
  32694. dispose(): void;
  32695. /**
  32696. * Gets the global volume sets on the master gain.
  32697. * @returns the global volume if set or -1 otherwise
  32698. */
  32699. getGlobalVolume(): number;
  32700. /**
  32701. * Sets the global volume of your experience (sets on the master gain).
  32702. * @param newVolume Defines the new global volume of the application
  32703. */
  32704. setGlobalVolume(newVolume: number): void;
  32705. /**
  32706. * Connect the audio engine to an audio analyser allowing some amazing
  32707. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32709. * @param analyser The analyser to connect to the engine
  32710. */
  32711. connectToAnalyser(analyser: Analyser): void;
  32712. }
  32713. }
  32714. declare module BABYLON {
  32715. /**
  32716. * Interface used to present a loading screen while loading a scene
  32717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32718. */
  32719. export interface ILoadingScreen {
  32720. /**
  32721. * Function called to display the loading screen
  32722. */
  32723. displayLoadingUI: () => void;
  32724. /**
  32725. * Function called to hide the loading screen
  32726. */
  32727. hideLoadingUI: () => void;
  32728. /**
  32729. * Gets or sets the color to use for the background
  32730. */
  32731. loadingUIBackgroundColor: string;
  32732. /**
  32733. * Gets or sets the text to display while loading
  32734. */
  32735. loadingUIText: string;
  32736. }
  32737. /**
  32738. * Class used for the default loading screen
  32739. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32740. */
  32741. export class DefaultLoadingScreen implements ILoadingScreen {
  32742. private _renderingCanvas;
  32743. private _loadingText;
  32744. private _loadingDivBackgroundColor;
  32745. private _loadingDiv;
  32746. private _loadingTextDiv;
  32747. /** Gets or sets the logo url to use for the default loading screen */
  32748. static DefaultLogoUrl: string;
  32749. /** Gets or sets the spinner url to use for the default loading screen */
  32750. static DefaultSpinnerUrl: string;
  32751. /**
  32752. * Creates a new default loading screen
  32753. * @param _renderingCanvas defines the canvas used to render the scene
  32754. * @param _loadingText defines the default text to display
  32755. * @param _loadingDivBackgroundColor defines the default background color
  32756. */
  32757. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32758. /**
  32759. * Function called to display the loading screen
  32760. */
  32761. displayLoadingUI(): void;
  32762. /**
  32763. * Function called to hide the loading screen
  32764. */
  32765. hideLoadingUI(): void;
  32766. /**
  32767. * Gets or sets the text to display while loading
  32768. */
  32769. set loadingUIText(text: string);
  32770. get loadingUIText(): string;
  32771. /**
  32772. * Gets or sets the color to use for the background
  32773. */
  32774. get loadingUIBackgroundColor(): string;
  32775. set loadingUIBackgroundColor(color: string);
  32776. private _resizeLoadingUI;
  32777. }
  32778. }
  32779. declare module BABYLON {
  32780. /**
  32781. * Interface for any object that can request an animation frame
  32782. */
  32783. export interface ICustomAnimationFrameRequester {
  32784. /**
  32785. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32786. */
  32787. renderFunction?: Function;
  32788. /**
  32789. * Called to request the next frame to render to
  32790. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32791. */
  32792. requestAnimationFrame: Function;
  32793. /**
  32794. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32795. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32796. */
  32797. requestID?: number;
  32798. }
  32799. }
  32800. declare module BABYLON {
  32801. /**
  32802. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32803. */
  32804. export class PerformanceMonitor {
  32805. private _enabled;
  32806. private _rollingFrameTime;
  32807. private _lastFrameTimeMs;
  32808. /**
  32809. * constructor
  32810. * @param frameSampleSize The number of samples required to saturate the sliding window
  32811. */
  32812. constructor(frameSampleSize?: number);
  32813. /**
  32814. * Samples current frame
  32815. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32816. */
  32817. sampleFrame(timeMs?: number): void;
  32818. /**
  32819. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32820. */
  32821. get averageFrameTime(): number;
  32822. /**
  32823. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32824. */
  32825. get averageFrameTimeVariance(): number;
  32826. /**
  32827. * Returns the frame time of the most recent frame
  32828. */
  32829. get instantaneousFrameTime(): number;
  32830. /**
  32831. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32832. */
  32833. get averageFPS(): number;
  32834. /**
  32835. * Returns the average framerate in frames per second using the most recent frame time
  32836. */
  32837. get instantaneousFPS(): number;
  32838. /**
  32839. * Returns true if enough samples have been taken to completely fill the sliding window
  32840. */
  32841. get isSaturated(): boolean;
  32842. /**
  32843. * Enables contributions to the sliding window sample set
  32844. */
  32845. enable(): void;
  32846. /**
  32847. * Disables contributions to the sliding window sample set
  32848. * Samples will not be interpolated over the disabled period
  32849. */
  32850. disable(): void;
  32851. /**
  32852. * Returns true if sampling is enabled
  32853. */
  32854. get isEnabled(): boolean;
  32855. /**
  32856. * Resets performance monitor
  32857. */
  32858. reset(): void;
  32859. }
  32860. /**
  32861. * RollingAverage
  32862. *
  32863. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32864. */
  32865. export class RollingAverage {
  32866. /**
  32867. * Current average
  32868. */
  32869. average: number;
  32870. /**
  32871. * Current variance
  32872. */
  32873. variance: number;
  32874. protected _samples: Array<number>;
  32875. protected _sampleCount: number;
  32876. protected _pos: number;
  32877. protected _m2: number;
  32878. /**
  32879. * constructor
  32880. * @param length The number of samples required to saturate the sliding window
  32881. */
  32882. constructor(length: number);
  32883. /**
  32884. * Adds a sample to the sample set
  32885. * @param v The sample value
  32886. */
  32887. add(v: number): void;
  32888. /**
  32889. * Returns previously added values or null if outside of history or outside the sliding window domain
  32890. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32891. * @return Value previously recorded with add() or null if outside of range
  32892. */
  32893. history(i: number): number;
  32894. /**
  32895. * Returns true if enough samples have been taken to completely fill the sliding window
  32896. * @return true if sample-set saturated
  32897. */
  32898. isSaturated(): boolean;
  32899. /**
  32900. * Resets the rolling average (equivalent to 0 samples taken so far)
  32901. */
  32902. reset(): void;
  32903. /**
  32904. * Wraps a value around the sample range boundaries
  32905. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32906. * @return Wrapped position in sample range
  32907. */
  32908. protected _wrapPosition(i: number): number;
  32909. }
  32910. }
  32911. declare module BABYLON {
  32912. /**
  32913. * This class is used to track a performance counter which is number based.
  32914. * The user has access to many properties which give statistics of different nature.
  32915. *
  32916. * The implementer can track two kinds of Performance Counter: time and count.
  32917. * 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.
  32918. * 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.
  32919. */
  32920. export class PerfCounter {
  32921. /**
  32922. * Gets or sets a global boolean to turn on and off all the counters
  32923. */
  32924. static Enabled: boolean;
  32925. /**
  32926. * Returns the smallest value ever
  32927. */
  32928. get min(): number;
  32929. /**
  32930. * Returns the biggest value ever
  32931. */
  32932. get max(): number;
  32933. /**
  32934. * Returns the average value since the performance counter is running
  32935. */
  32936. get average(): number;
  32937. /**
  32938. * Returns the average value of the last second the counter was monitored
  32939. */
  32940. get lastSecAverage(): number;
  32941. /**
  32942. * Returns the current value
  32943. */
  32944. get current(): number;
  32945. /**
  32946. * Gets the accumulated total
  32947. */
  32948. get total(): number;
  32949. /**
  32950. * Gets the total value count
  32951. */
  32952. get count(): number;
  32953. /**
  32954. * Creates a new counter
  32955. */
  32956. constructor();
  32957. /**
  32958. * Call this method to start monitoring a new frame.
  32959. * 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.
  32960. */
  32961. fetchNewFrame(): void;
  32962. /**
  32963. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32964. * @param newCount the count value to add to the monitored count
  32965. * @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.
  32966. */
  32967. addCount(newCount: number, fetchResult: boolean): void;
  32968. /**
  32969. * Start monitoring this performance counter
  32970. */
  32971. beginMonitoring(): void;
  32972. /**
  32973. * Compute the time lapsed since the previous beginMonitoring() call.
  32974. * @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
  32975. */
  32976. endMonitoring(newFrame?: boolean): void;
  32977. private _fetchResult;
  32978. private _startMonitoringTime;
  32979. private _min;
  32980. private _max;
  32981. private _average;
  32982. private _current;
  32983. private _totalValueCount;
  32984. private _totalAccumulated;
  32985. private _lastSecAverage;
  32986. private _lastSecAccumulated;
  32987. private _lastSecTime;
  32988. private _lastSecValueCount;
  32989. }
  32990. }
  32991. declare module BABYLON {
  32992. interface ThinEngine {
  32993. /**
  32994. * Sets alpha constants used by some alpha blending modes
  32995. * @param r defines the red component
  32996. * @param g defines the green component
  32997. * @param b defines the blue component
  32998. * @param a defines the alpha component
  32999. */
  33000. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33001. /**
  33002. * Sets the current alpha mode
  33003. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33004. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33005. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33006. */
  33007. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33008. /**
  33009. * Gets the current alpha mode
  33010. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33011. * @returns the current alpha mode
  33012. */
  33013. getAlphaMode(): number;
  33014. /**
  33015. * Sets the current alpha equation
  33016. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33017. */
  33018. setAlphaEquation(equation: number): void;
  33019. /**
  33020. * Gets the current alpha equation.
  33021. * @returns the current alpha equation
  33022. */
  33023. getAlphaEquation(): number;
  33024. }
  33025. }
  33026. declare module BABYLON {
  33027. /**
  33028. * Defines the interface used by display changed events
  33029. */
  33030. export interface IDisplayChangedEventArgs {
  33031. /** Gets the vrDisplay object (if any) */
  33032. vrDisplay: Nullable<any>;
  33033. /** Gets a boolean indicating if webVR is supported */
  33034. vrSupported: boolean;
  33035. }
  33036. /**
  33037. * Defines the interface used by objects containing a viewport (like a camera)
  33038. */
  33039. interface IViewportOwnerLike {
  33040. /**
  33041. * Gets or sets the viewport
  33042. */
  33043. viewport: IViewportLike;
  33044. }
  33045. /**
  33046. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33047. */
  33048. export class Engine extends ThinEngine {
  33049. /** Defines that alpha blending is disabled */
  33050. static readonly ALPHA_DISABLE: number;
  33051. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33052. static readonly ALPHA_ADD: number;
  33053. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33054. static readonly ALPHA_COMBINE: number;
  33055. /** Defines that alpha blending to DEST - SRC * DEST */
  33056. static readonly ALPHA_SUBTRACT: number;
  33057. /** Defines that alpha blending to SRC * DEST */
  33058. static readonly ALPHA_MULTIPLY: number;
  33059. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33060. static readonly ALPHA_MAXIMIZED: number;
  33061. /** Defines that alpha blending to SRC + DEST */
  33062. static readonly ALPHA_ONEONE: number;
  33063. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33064. static readonly ALPHA_PREMULTIPLIED: number;
  33065. /**
  33066. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33067. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33068. */
  33069. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33070. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33071. static readonly ALPHA_INTERPOLATE: number;
  33072. /**
  33073. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33074. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33075. */
  33076. static readonly ALPHA_SCREENMODE: number;
  33077. /** Defines that the ressource is not delayed*/
  33078. static readonly DELAYLOADSTATE_NONE: number;
  33079. /** Defines that the ressource was successfully delay loaded */
  33080. static readonly DELAYLOADSTATE_LOADED: number;
  33081. /** Defines that the ressource is currently delay loading */
  33082. static readonly DELAYLOADSTATE_LOADING: number;
  33083. /** Defines that the ressource is delayed and has not started loading */
  33084. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33085. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33086. static readonly NEVER: number;
  33087. /** 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 */
  33088. static readonly ALWAYS: number;
  33089. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33090. static readonly LESS: number;
  33091. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33092. static readonly EQUAL: number;
  33093. /** 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 */
  33094. static readonly LEQUAL: number;
  33095. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33096. static readonly GREATER: number;
  33097. /** 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 */
  33098. static readonly GEQUAL: number;
  33099. /** 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 */
  33100. static readonly NOTEQUAL: number;
  33101. /** Passed to stencilOperation to specify that stencil value must be kept */
  33102. static readonly KEEP: number;
  33103. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33104. static readonly REPLACE: number;
  33105. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33106. static readonly INCR: number;
  33107. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33108. static readonly DECR: number;
  33109. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33110. static readonly INVERT: number;
  33111. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33112. static readonly INCR_WRAP: number;
  33113. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33114. static readonly DECR_WRAP: number;
  33115. /** Texture is not repeating outside of 0..1 UVs */
  33116. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33117. /** Texture is repeating outside of 0..1 UVs */
  33118. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33119. /** Texture is repeating and mirrored */
  33120. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33121. /** ALPHA */
  33122. static readonly TEXTUREFORMAT_ALPHA: number;
  33123. /** LUMINANCE */
  33124. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33125. /** LUMINANCE_ALPHA */
  33126. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33127. /** RGB */
  33128. static readonly TEXTUREFORMAT_RGB: number;
  33129. /** RGBA */
  33130. static readonly TEXTUREFORMAT_RGBA: number;
  33131. /** RED */
  33132. static readonly TEXTUREFORMAT_RED: number;
  33133. /** RED (2nd reference) */
  33134. static readonly TEXTUREFORMAT_R: number;
  33135. /** RG */
  33136. static readonly TEXTUREFORMAT_RG: number;
  33137. /** RED_INTEGER */
  33138. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33139. /** RED_INTEGER (2nd reference) */
  33140. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33141. /** RG_INTEGER */
  33142. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33143. /** RGB_INTEGER */
  33144. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33145. /** RGBA_INTEGER */
  33146. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33147. /** UNSIGNED_BYTE */
  33148. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33149. /** UNSIGNED_BYTE (2nd reference) */
  33150. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33151. /** FLOAT */
  33152. static readonly TEXTURETYPE_FLOAT: number;
  33153. /** HALF_FLOAT */
  33154. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33155. /** BYTE */
  33156. static readonly TEXTURETYPE_BYTE: number;
  33157. /** SHORT */
  33158. static readonly TEXTURETYPE_SHORT: number;
  33159. /** UNSIGNED_SHORT */
  33160. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33161. /** INT */
  33162. static readonly TEXTURETYPE_INT: number;
  33163. /** UNSIGNED_INT */
  33164. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33165. /** UNSIGNED_SHORT_4_4_4_4 */
  33166. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33167. /** UNSIGNED_SHORT_5_5_5_1 */
  33168. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33169. /** UNSIGNED_SHORT_5_6_5 */
  33170. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33171. /** UNSIGNED_INT_2_10_10_10_REV */
  33172. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33173. /** UNSIGNED_INT_24_8 */
  33174. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33175. /** UNSIGNED_INT_10F_11F_11F_REV */
  33176. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33177. /** UNSIGNED_INT_5_9_9_9_REV */
  33178. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33179. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33180. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33181. /** nearest is mag = nearest and min = nearest and mip = linear */
  33182. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33183. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33184. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33185. /** Trilinear is mag = linear and min = linear and mip = linear */
  33186. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33187. /** nearest is mag = nearest and min = nearest and mip = linear */
  33188. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33189. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33190. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33191. /** Trilinear is mag = linear and min = linear and mip = linear */
  33192. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33193. /** mag = nearest and min = nearest and mip = nearest */
  33194. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33195. /** mag = nearest and min = linear and mip = nearest */
  33196. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33197. /** mag = nearest and min = linear and mip = linear */
  33198. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33199. /** mag = nearest and min = linear and mip = none */
  33200. static readonly TEXTURE_NEAREST_LINEAR: number;
  33201. /** mag = nearest and min = nearest and mip = none */
  33202. static readonly TEXTURE_NEAREST_NEAREST: number;
  33203. /** mag = linear and min = nearest and mip = nearest */
  33204. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33205. /** mag = linear and min = nearest and mip = linear */
  33206. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33207. /** mag = linear and min = linear and mip = none */
  33208. static readonly TEXTURE_LINEAR_LINEAR: number;
  33209. /** mag = linear and min = nearest and mip = none */
  33210. static readonly TEXTURE_LINEAR_NEAREST: number;
  33211. /** Explicit coordinates mode */
  33212. static readonly TEXTURE_EXPLICIT_MODE: number;
  33213. /** Spherical coordinates mode */
  33214. static readonly TEXTURE_SPHERICAL_MODE: number;
  33215. /** Planar coordinates mode */
  33216. static readonly TEXTURE_PLANAR_MODE: number;
  33217. /** Cubic coordinates mode */
  33218. static readonly TEXTURE_CUBIC_MODE: number;
  33219. /** Projection coordinates mode */
  33220. static readonly TEXTURE_PROJECTION_MODE: number;
  33221. /** Skybox coordinates mode */
  33222. static readonly TEXTURE_SKYBOX_MODE: number;
  33223. /** Inverse Cubic coordinates mode */
  33224. static readonly TEXTURE_INVCUBIC_MODE: number;
  33225. /** Equirectangular coordinates mode */
  33226. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33227. /** Equirectangular Fixed coordinates mode */
  33228. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33229. /** Equirectangular Fixed Mirrored coordinates mode */
  33230. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33231. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33232. static readonly SCALEMODE_FLOOR: number;
  33233. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33234. static readonly SCALEMODE_NEAREST: number;
  33235. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33236. static readonly SCALEMODE_CEILING: number;
  33237. /**
  33238. * Returns the current npm package of the sdk
  33239. */
  33240. static get NpmPackage(): string;
  33241. /**
  33242. * Returns the current version of the framework
  33243. */
  33244. static get Version(): string;
  33245. /** Gets the list of created engines */
  33246. static get Instances(): Engine[];
  33247. /**
  33248. * Gets the latest created engine
  33249. */
  33250. static get LastCreatedEngine(): Nullable<Engine>;
  33251. /**
  33252. * Gets the latest created scene
  33253. */
  33254. static get LastCreatedScene(): Nullable<Scene>;
  33255. /**
  33256. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33257. * @param flag defines which part of the materials must be marked as dirty
  33258. * @param predicate defines a predicate used to filter which materials should be affected
  33259. */
  33260. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33261. /**
  33262. * Method called to create the default loading screen.
  33263. * This can be overriden in your own app.
  33264. * @param canvas The rendering canvas element
  33265. * @returns The loading screen
  33266. */
  33267. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33268. /**
  33269. * Method called to create the default rescale post process on each engine.
  33270. */
  33271. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33272. /**
  33273. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33274. **/
  33275. enableOfflineSupport: boolean;
  33276. /**
  33277. * 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)
  33278. **/
  33279. disableManifestCheck: boolean;
  33280. /**
  33281. * Gets the list of created scenes
  33282. */
  33283. scenes: Scene[];
  33284. /**
  33285. * Event raised when a new scene is created
  33286. */
  33287. onNewSceneAddedObservable: Observable<Scene>;
  33288. /**
  33289. * Gets the list of created postprocesses
  33290. */
  33291. postProcesses: PostProcess[];
  33292. /**
  33293. * Gets a boolean indicating if the pointer is currently locked
  33294. */
  33295. isPointerLock: boolean;
  33296. /**
  33297. * Observable event triggered each time the rendering canvas is resized
  33298. */
  33299. onResizeObservable: Observable<Engine>;
  33300. /**
  33301. * Observable event triggered each time the canvas loses focus
  33302. */
  33303. onCanvasBlurObservable: Observable<Engine>;
  33304. /**
  33305. * Observable event triggered each time the canvas gains focus
  33306. */
  33307. onCanvasFocusObservable: Observable<Engine>;
  33308. /**
  33309. * Observable event triggered each time the canvas receives pointerout event
  33310. */
  33311. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33312. /**
  33313. * Observable raised when the engine begins a new frame
  33314. */
  33315. onBeginFrameObservable: Observable<Engine>;
  33316. /**
  33317. * If set, will be used to request the next animation frame for the render loop
  33318. */
  33319. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33320. /**
  33321. * Observable raised when the engine ends the current frame
  33322. */
  33323. onEndFrameObservable: Observable<Engine>;
  33324. /**
  33325. * Observable raised when the engine is about to compile a shader
  33326. */
  33327. onBeforeShaderCompilationObservable: Observable<Engine>;
  33328. /**
  33329. * Observable raised when the engine has jsut compiled a shader
  33330. */
  33331. onAfterShaderCompilationObservable: Observable<Engine>;
  33332. /**
  33333. * Gets the audio engine
  33334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33335. * @ignorenaming
  33336. */
  33337. static audioEngine: IAudioEngine;
  33338. /**
  33339. * Default AudioEngine factory responsible of creating the Audio Engine.
  33340. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33341. */
  33342. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33343. /**
  33344. * Default offline support factory responsible of creating a tool used to store data locally.
  33345. * By default, this will create a Database object if the workload has been embedded.
  33346. */
  33347. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33348. private _loadingScreen;
  33349. private _pointerLockRequested;
  33350. private _dummyFramebuffer;
  33351. private _rescalePostProcess;
  33352. private _deterministicLockstep;
  33353. private _lockstepMaxSteps;
  33354. private _timeStep;
  33355. protected get _supportsHardwareTextureRescaling(): boolean;
  33356. private _fps;
  33357. private _deltaTime;
  33358. /** @hidden */
  33359. _drawCalls: PerfCounter;
  33360. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33361. canvasTabIndex: number;
  33362. /**
  33363. * Turn this value on if you want to pause FPS computation when in background
  33364. */
  33365. disablePerformanceMonitorInBackground: boolean;
  33366. private _performanceMonitor;
  33367. /**
  33368. * Gets the performance monitor attached to this engine
  33369. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33370. */
  33371. get performanceMonitor(): PerformanceMonitor;
  33372. private _onFocus;
  33373. private _onBlur;
  33374. private _onCanvasPointerOut;
  33375. private _onCanvasBlur;
  33376. private _onCanvasFocus;
  33377. private _onFullscreenChange;
  33378. private _onPointerLockChange;
  33379. /**
  33380. * Gets the HTML element used to attach event listeners
  33381. * @returns a HTML element
  33382. */
  33383. getInputElement(): Nullable<HTMLElement>;
  33384. /**
  33385. * Creates a new engine
  33386. * @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
  33387. * @param antialias defines enable antialiasing (default: false)
  33388. * @param options defines further options to be sent to the getContext() function
  33389. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33390. */
  33391. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33392. /**
  33393. * Gets current aspect ratio
  33394. * @param viewportOwner defines the camera to use to get the aspect ratio
  33395. * @param useScreen defines if screen size must be used (or the current render target if any)
  33396. * @returns a number defining the aspect ratio
  33397. */
  33398. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33399. /**
  33400. * Gets current screen aspect ratio
  33401. * @returns a number defining the aspect ratio
  33402. */
  33403. getScreenAspectRatio(): number;
  33404. /**
  33405. * Gets the client rect of the HTML canvas attached with the current webGL context
  33406. * @returns a client rectanglee
  33407. */
  33408. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33409. /**
  33410. * Gets the client rect of the HTML element used for events
  33411. * @returns a client rectanglee
  33412. */
  33413. getInputElementClientRect(): Nullable<ClientRect>;
  33414. /**
  33415. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33416. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33417. * @returns true if engine is in deterministic lock step mode
  33418. */
  33419. isDeterministicLockStep(): boolean;
  33420. /**
  33421. * Gets the max steps when engine is running in deterministic lock step
  33422. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33423. * @returns the max steps
  33424. */
  33425. getLockstepMaxSteps(): number;
  33426. /**
  33427. * Returns the time in ms between steps when using deterministic lock step.
  33428. * @returns time step in (ms)
  33429. */
  33430. getTimeStep(): number;
  33431. /**
  33432. * Force the mipmap generation for the given render target texture
  33433. * @param texture defines the render target texture to use
  33434. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33435. */
  33436. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33437. /** States */
  33438. /**
  33439. * Set various states to the webGL context
  33440. * @param culling defines backface culling state
  33441. * @param zOffset defines the value to apply to zOffset (0 by default)
  33442. * @param force defines if states must be applied even if cache is up to date
  33443. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33444. */
  33445. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33446. /**
  33447. * Set the z offset to apply to current rendering
  33448. * @param value defines the offset to apply
  33449. */
  33450. setZOffset(value: number): void;
  33451. /**
  33452. * Gets the current value of the zOffset
  33453. * @returns the current zOffset state
  33454. */
  33455. getZOffset(): number;
  33456. /**
  33457. * Enable or disable depth buffering
  33458. * @param enable defines the state to set
  33459. */
  33460. setDepthBuffer(enable: boolean): void;
  33461. /**
  33462. * Gets a boolean indicating if depth writing is enabled
  33463. * @returns the current depth writing state
  33464. */
  33465. getDepthWrite(): boolean;
  33466. /**
  33467. * Enable or disable depth writing
  33468. * @param enable defines the state to set
  33469. */
  33470. setDepthWrite(enable: boolean): void;
  33471. /**
  33472. * Gets a boolean indicating if stencil buffer is enabled
  33473. * @returns the current stencil buffer state
  33474. */
  33475. getStencilBuffer(): boolean;
  33476. /**
  33477. * Enable or disable the stencil buffer
  33478. * @param enable defines if the stencil buffer must be enabled or disabled
  33479. */
  33480. setStencilBuffer(enable: boolean): void;
  33481. /**
  33482. * Gets the current stencil mask
  33483. * @returns a number defining the new stencil mask to use
  33484. */
  33485. getStencilMask(): number;
  33486. /**
  33487. * Sets the current stencil mask
  33488. * @param mask defines the new stencil mask to use
  33489. */
  33490. setStencilMask(mask: number): void;
  33491. /**
  33492. * Gets the current stencil function
  33493. * @returns a number defining the stencil function to use
  33494. */
  33495. getStencilFunction(): number;
  33496. /**
  33497. * Gets the current stencil reference value
  33498. * @returns a number defining the stencil reference value to use
  33499. */
  33500. getStencilFunctionReference(): number;
  33501. /**
  33502. * Gets the current stencil mask
  33503. * @returns a number defining the stencil mask to use
  33504. */
  33505. getStencilFunctionMask(): number;
  33506. /**
  33507. * Sets the current stencil function
  33508. * @param stencilFunc defines the new stencil function to use
  33509. */
  33510. setStencilFunction(stencilFunc: number): void;
  33511. /**
  33512. * Sets the current stencil reference
  33513. * @param reference defines the new stencil reference to use
  33514. */
  33515. setStencilFunctionReference(reference: number): void;
  33516. /**
  33517. * Sets the current stencil mask
  33518. * @param mask defines the new stencil mask to use
  33519. */
  33520. setStencilFunctionMask(mask: number): void;
  33521. /**
  33522. * Gets the current stencil operation when stencil fails
  33523. * @returns a number defining stencil operation to use when stencil fails
  33524. */
  33525. getStencilOperationFail(): number;
  33526. /**
  33527. * Gets the current stencil operation when depth fails
  33528. * @returns a number defining stencil operation to use when depth fails
  33529. */
  33530. getStencilOperationDepthFail(): number;
  33531. /**
  33532. * Gets the current stencil operation when stencil passes
  33533. * @returns a number defining stencil operation to use when stencil passes
  33534. */
  33535. getStencilOperationPass(): number;
  33536. /**
  33537. * Sets the stencil operation to use when stencil fails
  33538. * @param operation defines the stencil operation to use when stencil fails
  33539. */
  33540. setStencilOperationFail(operation: number): void;
  33541. /**
  33542. * Sets the stencil operation to use when depth fails
  33543. * @param operation defines the stencil operation to use when depth fails
  33544. */
  33545. setStencilOperationDepthFail(operation: number): void;
  33546. /**
  33547. * Sets the stencil operation to use when stencil passes
  33548. * @param operation defines the stencil operation to use when stencil passes
  33549. */
  33550. setStencilOperationPass(operation: number): void;
  33551. /**
  33552. * Sets a boolean indicating if the dithering state is enabled or disabled
  33553. * @param value defines the dithering state
  33554. */
  33555. setDitheringState(value: boolean): void;
  33556. /**
  33557. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33558. * @param value defines the rasterizer state
  33559. */
  33560. setRasterizerState(value: boolean): void;
  33561. /**
  33562. * Gets the current depth function
  33563. * @returns a number defining the depth function
  33564. */
  33565. getDepthFunction(): Nullable<number>;
  33566. /**
  33567. * Sets the current depth function
  33568. * @param depthFunc defines the function to use
  33569. */
  33570. setDepthFunction(depthFunc: number): void;
  33571. /**
  33572. * Sets the current depth function to GREATER
  33573. */
  33574. setDepthFunctionToGreater(): void;
  33575. /**
  33576. * Sets the current depth function to GEQUAL
  33577. */
  33578. setDepthFunctionToGreaterOrEqual(): void;
  33579. /**
  33580. * Sets the current depth function to LESS
  33581. */
  33582. setDepthFunctionToLess(): void;
  33583. /**
  33584. * Sets the current depth function to LEQUAL
  33585. */
  33586. setDepthFunctionToLessOrEqual(): void;
  33587. private _cachedStencilBuffer;
  33588. private _cachedStencilFunction;
  33589. private _cachedStencilMask;
  33590. private _cachedStencilOperationPass;
  33591. private _cachedStencilOperationFail;
  33592. private _cachedStencilOperationDepthFail;
  33593. private _cachedStencilReference;
  33594. /**
  33595. * Caches the the state of the stencil buffer
  33596. */
  33597. cacheStencilState(): void;
  33598. /**
  33599. * Restores the state of the stencil buffer
  33600. */
  33601. restoreStencilState(): void;
  33602. /**
  33603. * Directly set the WebGL Viewport
  33604. * @param x defines the x coordinate of the viewport (in screen space)
  33605. * @param y defines the y coordinate of the viewport (in screen space)
  33606. * @param width defines the width of the viewport (in screen space)
  33607. * @param height defines the height of the viewport (in screen space)
  33608. * @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
  33609. */
  33610. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33611. /**
  33612. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33613. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33614. * @param y defines the y-coordinate of the corner of the clear rectangle
  33615. * @param width defines the width of the clear rectangle
  33616. * @param height defines the height of the clear rectangle
  33617. * @param clearColor defines the clear color
  33618. */
  33619. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33620. /**
  33621. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33622. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33623. * @param y defines the y-coordinate of the corner of the clear rectangle
  33624. * @param width defines the width of the clear rectangle
  33625. * @param height defines the height of the clear rectangle
  33626. */
  33627. enableScissor(x: number, y: number, width: number, height: number): void;
  33628. /**
  33629. * Disable previously set scissor test rectangle
  33630. */
  33631. disableScissor(): void;
  33632. protected _reportDrawCall(): void;
  33633. /**
  33634. * Initializes a webVR display and starts listening to display change events
  33635. * The onVRDisplayChangedObservable will be notified upon these changes
  33636. * @returns The onVRDisplayChangedObservable
  33637. */
  33638. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33639. /** @hidden */
  33640. _prepareVRComponent(): void;
  33641. /** @hidden */
  33642. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33643. /** @hidden */
  33644. _submitVRFrame(): void;
  33645. /**
  33646. * Call this function to leave webVR mode
  33647. * Will do nothing if webVR is not supported or if there is no webVR device
  33648. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33649. */
  33650. disableVR(): void;
  33651. /**
  33652. * Gets a boolean indicating that the system is in VR mode and is presenting
  33653. * @returns true if VR mode is engaged
  33654. */
  33655. isVRPresenting(): boolean;
  33656. /** @hidden */
  33657. _requestVRFrame(): void;
  33658. /** @hidden */
  33659. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33660. /**
  33661. * Gets the source code of the vertex shader associated with a specific webGL program
  33662. * @param program defines the program to use
  33663. * @returns a string containing the source code of the vertex shader associated with the program
  33664. */
  33665. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33666. /**
  33667. * Gets the source code of the fragment shader associated with a specific webGL program
  33668. * @param program defines the program to use
  33669. * @returns a string containing the source code of the fragment shader associated with the program
  33670. */
  33671. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33672. /**
  33673. * Sets a depth stencil texture from a render target to the according uniform.
  33674. * @param channel The texture channel
  33675. * @param uniform The uniform to set
  33676. * @param texture The render target texture containing the depth stencil texture to apply
  33677. */
  33678. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33679. /**
  33680. * Sets a texture to the webGL context from a postprocess
  33681. * @param channel defines the channel to use
  33682. * @param postProcess defines the source postprocess
  33683. */
  33684. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33685. /**
  33686. * Binds the output of the passed in post process to the texture channel specified
  33687. * @param channel The channel the texture should be bound to
  33688. * @param postProcess The post process which's output should be bound
  33689. */
  33690. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33691. /** @hidden */
  33692. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33693. protected _rebuildBuffers(): void;
  33694. /** @hidden */
  33695. _renderFrame(): void;
  33696. _renderLoop(): void;
  33697. /** @hidden */
  33698. _renderViews(): boolean;
  33699. /**
  33700. * Toggle full screen mode
  33701. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33702. */
  33703. switchFullscreen(requestPointerLock: boolean): void;
  33704. /**
  33705. * Enters full screen mode
  33706. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33707. */
  33708. enterFullscreen(requestPointerLock: boolean): void;
  33709. /**
  33710. * Exits full screen mode
  33711. */
  33712. exitFullscreen(): void;
  33713. /**
  33714. * Enters Pointerlock mode
  33715. */
  33716. enterPointerlock(): void;
  33717. /**
  33718. * Exits Pointerlock mode
  33719. */
  33720. exitPointerlock(): void;
  33721. /**
  33722. * Begin a new frame
  33723. */
  33724. beginFrame(): void;
  33725. /**
  33726. * Enf the current frame
  33727. */
  33728. endFrame(): void;
  33729. resize(): void;
  33730. /**
  33731. * Set the compressed texture format to use, based on the formats you have, and the formats
  33732. * supported by the hardware / browser.
  33733. *
  33734. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33735. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33736. * to API arguments needed to compressed textures. This puts the burden on the container
  33737. * generator to house the arcane code for determining these for current & future formats.
  33738. *
  33739. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33740. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33741. *
  33742. * Note: The result of this call is not taken into account when a texture is base64.
  33743. *
  33744. * @param formatsAvailable defines the list of those format families you have created
  33745. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33746. *
  33747. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33748. * @returns The extension selected.
  33749. */
  33750. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33751. /**
  33752. * Set the compressed texture extensions or file names to skip.
  33753. *
  33754. * @param skippedFiles defines the list of those texture files you want to skip
  33755. * Example: [".dds", ".env", "myfile.png"]
  33756. */
  33757. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33758. /**
  33759. * Force a specific size of the canvas
  33760. * @param width defines the new canvas' width
  33761. * @param height defines the new canvas' height
  33762. */
  33763. setSize(width: number, height: number): void;
  33764. /**
  33765. * Updates a dynamic vertex buffer.
  33766. * @param vertexBuffer the vertex buffer to update
  33767. * @param data the data used to update the vertex buffer
  33768. * @param byteOffset the byte offset of the data
  33769. * @param byteLength the byte length of the data
  33770. */
  33771. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33772. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33773. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33774. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33775. _releaseTexture(texture: InternalTexture): void;
  33776. /**
  33777. * @hidden
  33778. * Rescales a texture
  33779. * @param source input texutre
  33780. * @param destination destination texture
  33781. * @param scene scene to use to render the resize
  33782. * @param internalFormat format to use when resizing
  33783. * @param onComplete callback to be called when resize has completed
  33784. */
  33785. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33786. /**
  33787. * Gets the current framerate
  33788. * @returns a number representing the framerate
  33789. */
  33790. getFps(): number;
  33791. /**
  33792. * Gets the time spent between current and previous frame
  33793. * @returns a number representing the delta time in ms
  33794. */
  33795. getDeltaTime(): number;
  33796. private _measureFps;
  33797. /** @hidden */
  33798. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33799. /**
  33800. * Update a dynamic index buffer
  33801. * @param indexBuffer defines the target index buffer
  33802. * @param indices defines the data to update
  33803. * @param offset defines the offset in the target index buffer where update should start
  33804. */
  33805. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33806. /**
  33807. * Updates the sample count of a render target texture
  33808. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33809. * @param texture defines the texture to update
  33810. * @param samples defines the sample count to set
  33811. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33812. */
  33813. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33814. /**
  33815. * Updates a depth texture Comparison Mode and Function.
  33816. * If the comparison Function is equal to 0, the mode will be set to none.
  33817. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33818. * @param texture The texture to set the comparison function for
  33819. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33820. */
  33821. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33822. /**
  33823. * Creates a webGL buffer to use with instanciation
  33824. * @param capacity defines the size of the buffer
  33825. * @returns the webGL buffer
  33826. */
  33827. createInstancesBuffer(capacity: number): DataBuffer;
  33828. /**
  33829. * Delete a webGL buffer used with instanciation
  33830. * @param buffer defines the webGL buffer to delete
  33831. */
  33832. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33833. private _clientWaitAsync;
  33834. /** @hidden */
  33835. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  33836. /** @hidden */
  33837. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33838. dispose(): void;
  33839. private _disableTouchAction;
  33840. /**
  33841. * Display the loading screen
  33842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33843. */
  33844. displayLoadingUI(): void;
  33845. /**
  33846. * Hide the loading screen
  33847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33848. */
  33849. hideLoadingUI(): void;
  33850. /**
  33851. * Gets the current loading screen object
  33852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33853. */
  33854. get loadingScreen(): ILoadingScreen;
  33855. /**
  33856. * Sets the current loading screen object
  33857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33858. */
  33859. set loadingScreen(loadingScreen: ILoadingScreen);
  33860. /**
  33861. * Sets the current loading screen text
  33862. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33863. */
  33864. set loadingUIText(text: string);
  33865. /**
  33866. * Sets the current loading screen background color
  33867. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33868. */
  33869. set loadingUIBackgroundColor(color: string);
  33870. /** Pointerlock and fullscreen */
  33871. /**
  33872. * Ask the browser to promote the current element to pointerlock mode
  33873. * @param element defines the DOM element to promote
  33874. */
  33875. static _RequestPointerlock(element: HTMLElement): void;
  33876. /**
  33877. * Asks the browser to exit pointerlock mode
  33878. */
  33879. static _ExitPointerlock(): void;
  33880. /**
  33881. * Ask the browser to promote the current element to fullscreen rendering mode
  33882. * @param element defines the DOM element to promote
  33883. */
  33884. static _RequestFullscreen(element: HTMLElement): void;
  33885. /**
  33886. * Asks the browser to exit fullscreen mode
  33887. */
  33888. static _ExitFullscreen(): void;
  33889. }
  33890. }
  33891. declare module BABYLON {
  33892. /**
  33893. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33894. * during the life time of the application.
  33895. */
  33896. export class EngineStore {
  33897. /** Gets the list of created engines */
  33898. static Instances: Engine[];
  33899. /** @hidden */
  33900. static _LastCreatedScene: Nullable<Scene>;
  33901. /**
  33902. * Gets the latest created engine
  33903. */
  33904. static get LastCreatedEngine(): Nullable<Engine>;
  33905. /**
  33906. * Gets the latest created scene
  33907. */
  33908. static get LastCreatedScene(): Nullable<Scene>;
  33909. /**
  33910. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33911. * @ignorenaming
  33912. */
  33913. static UseFallbackTexture: boolean;
  33914. /**
  33915. * Texture content used if a texture cannot loaded
  33916. * @ignorenaming
  33917. */
  33918. static FallbackTexture: string;
  33919. }
  33920. }
  33921. declare module BABYLON {
  33922. /**
  33923. * Helper class that provides a small promise polyfill
  33924. */
  33925. export class PromisePolyfill {
  33926. /**
  33927. * Static function used to check if the polyfill is required
  33928. * If this is the case then the function will inject the polyfill to window.Promise
  33929. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33930. */
  33931. static Apply(force?: boolean): void;
  33932. }
  33933. }
  33934. declare module BABYLON {
  33935. /**
  33936. * Interface for screenshot methods with describe argument called `size` as object with options
  33937. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33938. */
  33939. export interface IScreenshotSize {
  33940. /**
  33941. * number in pixels for canvas height
  33942. */
  33943. height?: number;
  33944. /**
  33945. * multiplier allowing render at a higher or lower resolution
  33946. * If value is defined then height and width will be ignored and taken from camera
  33947. */
  33948. precision?: number;
  33949. /**
  33950. * number in pixels for canvas width
  33951. */
  33952. width?: number;
  33953. }
  33954. }
  33955. declare module BABYLON {
  33956. interface IColor4Like {
  33957. r: float;
  33958. g: float;
  33959. b: float;
  33960. a: float;
  33961. }
  33962. /**
  33963. * Class containing a set of static utilities functions
  33964. */
  33965. export class Tools {
  33966. /**
  33967. * Gets or sets the base URL to use to load assets
  33968. */
  33969. static get BaseUrl(): string;
  33970. static set BaseUrl(value: string);
  33971. /**
  33972. * Enable/Disable Custom HTTP Request Headers globally.
  33973. * default = false
  33974. * @see CustomRequestHeaders
  33975. */
  33976. static UseCustomRequestHeaders: boolean;
  33977. /**
  33978. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33979. * i.e. when loading files, where the server/service expects an Authorization header
  33980. */
  33981. static CustomRequestHeaders: {
  33982. [key: string]: string;
  33983. };
  33984. /**
  33985. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33986. */
  33987. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33988. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33989. /**
  33990. * Default behaviour for cors in the application.
  33991. * It can be a string if the expected behavior is identical in the entire app.
  33992. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33993. */
  33994. static CorsBehavior: string | ((url: string | string[]) => string);
  33995. /**
  33996. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33997. * @ignorenaming
  33998. */
  33999. static get UseFallbackTexture(): boolean;
  34000. static set UseFallbackTexture(value: boolean);
  34001. /**
  34002. * Use this object to register external classes like custom textures or material
  34003. * to allow the laoders to instantiate them
  34004. */
  34005. static get RegisteredExternalClasses(): {
  34006. [key: string]: Object;
  34007. };
  34008. static set RegisteredExternalClasses(classes: {
  34009. [key: string]: Object;
  34010. });
  34011. /**
  34012. * Texture content used if a texture cannot loaded
  34013. * @ignorenaming
  34014. */
  34015. static get fallbackTexture(): string;
  34016. static set fallbackTexture(value: string);
  34017. /**
  34018. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34019. * @param u defines the coordinate on X axis
  34020. * @param v defines the coordinate on Y axis
  34021. * @param width defines the width of the source data
  34022. * @param height defines the height of the source data
  34023. * @param pixels defines the source byte array
  34024. * @param color defines the output color
  34025. */
  34026. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34027. /**
  34028. * Interpolates between a and b via alpha
  34029. * @param a The lower value (returned when alpha = 0)
  34030. * @param b The upper value (returned when alpha = 1)
  34031. * @param alpha The interpolation-factor
  34032. * @return The mixed value
  34033. */
  34034. static Mix(a: number, b: number, alpha: number): number;
  34035. /**
  34036. * Tries to instantiate a new object from a given class name
  34037. * @param className defines the class name to instantiate
  34038. * @returns the new object or null if the system was not able to do the instantiation
  34039. */
  34040. static Instantiate(className: string): any;
  34041. /**
  34042. * Provides a slice function that will work even on IE
  34043. * @param data defines the array to slice
  34044. * @param start defines the start of the data (optional)
  34045. * @param end defines the end of the data (optional)
  34046. * @returns the new sliced array
  34047. */
  34048. static Slice<T>(data: T, start?: number, end?: number): T;
  34049. /**
  34050. * Polyfill for setImmediate
  34051. * @param action defines the action to execute after the current execution block
  34052. */
  34053. static SetImmediate(action: () => void): void;
  34054. /**
  34055. * Function indicating if a number is an exponent of 2
  34056. * @param value defines the value to test
  34057. * @returns true if the value is an exponent of 2
  34058. */
  34059. static IsExponentOfTwo(value: number): boolean;
  34060. private static _tmpFloatArray;
  34061. /**
  34062. * Returns the nearest 32-bit single precision float representation of a Number
  34063. * @param value A Number. If the parameter is of a different type, it will get converted
  34064. * to a number or to NaN if it cannot be converted
  34065. * @returns number
  34066. */
  34067. static FloatRound(value: number): number;
  34068. /**
  34069. * Extracts the filename from a path
  34070. * @param path defines the path to use
  34071. * @returns the filename
  34072. */
  34073. static GetFilename(path: string): string;
  34074. /**
  34075. * Extracts the "folder" part of a path (everything before the filename).
  34076. * @param uri The URI to extract the info from
  34077. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34078. * @returns The "folder" part of the path
  34079. */
  34080. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34081. /**
  34082. * Extracts text content from a DOM element hierarchy
  34083. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34084. */
  34085. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34086. /**
  34087. * Convert an angle in radians to degrees
  34088. * @param angle defines the angle to convert
  34089. * @returns the angle in degrees
  34090. */
  34091. static ToDegrees(angle: number): number;
  34092. /**
  34093. * Convert an angle in degrees to radians
  34094. * @param angle defines the angle to convert
  34095. * @returns the angle in radians
  34096. */
  34097. static ToRadians(angle: number): number;
  34098. /**
  34099. * Returns an array if obj is not an array
  34100. * @param obj defines the object to evaluate as an array
  34101. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34102. * @returns either obj directly if obj is an array or a new array containing obj
  34103. */
  34104. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34105. /**
  34106. * Gets the pointer prefix to use
  34107. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34108. */
  34109. static GetPointerPrefix(): string;
  34110. /**
  34111. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34112. * @param url define the url we are trying
  34113. * @param element define the dom element where to configure the cors policy
  34114. */
  34115. static SetCorsBehavior(url: string | string[], element: {
  34116. crossOrigin: string | null;
  34117. }): void;
  34118. /**
  34119. * Removes unwanted characters from an url
  34120. * @param url defines the url to clean
  34121. * @returns the cleaned url
  34122. */
  34123. static CleanUrl(url: string): string;
  34124. /**
  34125. * Gets or sets a function used to pre-process url before using them to load assets
  34126. */
  34127. static get PreprocessUrl(): (url: string) => string;
  34128. static set PreprocessUrl(processor: (url: string) => string);
  34129. /**
  34130. * Loads an image as an HTMLImageElement.
  34131. * @param input url string, ArrayBuffer, or Blob to load
  34132. * @param onLoad callback called when the image successfully loads
  34133. * @param onError callback called when the image fails to load
  34134. * @param offlineProvider offline provider for caching
  34135. * @param mimeType optional mime type
  34136. * @returns the HTMLImageElement of the loaded image
  34137. */
  34138. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34139. /**
  34140. * Loads a file from a url
  34141. * @param url url string, ArrayBuffer, or Blob to load
  34142. * @param onSuccess callback called when the file successfully loads
  34143. * @param onProgress callback called while file is loading (if the server supports this mode)
  34144. * @param offlineProvider defines the offline provider for caching
  34145. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34146. * @param onError callback called when the file fails to load
  34147. * @returns a file request object
  34148. */
  34149. 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;
  34150. /**
  34151. * Loads a file from a url
  34152. * @param url the file url to load
  34153. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34154. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34155. */
  34156. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34157. /**
  34158. * Load a script (identified by an url). When the url returns, the
  34159. * content of this file is added into a new script element, attached to the DOM (body element)
  34160. * @param scriptUrl defines the url of the script to laod
  34161. * @param onSuccess defines the callback called when the script is loaded
  34162. * @param onError defines the callback to call if an error occurs
  34163. * @param scriptId defines the id of the script element
  34164. */
  34165. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34166. /**
  34167. * Load an asynchronous script (identified by an url). When the url returns, the
  34168. * content of this file is added into a new script element, attached to the DOM (body element)
  34169. * @param scriptUrl defines the url of the script to laod
  34170. * @param scriptId defines the id of the script element
  34171. * @returns a promise request object
  34172. */
  34173. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34174. /**
  34175. * Loads a file from a blob
  34176. * @param fileToLoad defines the blob to use
  34177. * @param callback defines the callback to call when data is loaded
  34178. * @param progressCallback defines the callback to call during loading process
  34179. * @returns a file request object
  34180. */
  34181. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34182. /**
  34183. * Reads a file from a File object
  34184. * @param file defines the file to load
  34185. * @param onSuccess defines the callback to call when data is loaded
  34186. * @param onProgress defines the callback to call during loading process
  34187. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34188. * @param onError defines the callback to call when an error occurs
  34189. * @returns a file request object
  34190. */
  34191. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34192. /**
  34193. * Creates a data url from a given string content
  34194. * @param content defines the content to convert
  34195. * @returns the new data url link
  34196. */
  34197. static FileAsURL(content: string): string;
  34198. /**
  34199. * Format the given number to a specific decimal format
  34200. * @param value defines the number to format
  34201. * @param decimals defines the number of decimals to use
  34202. * @returns the formatted string
  34203. */
  34204. static Format(value: number, decimals?: number): string;
  34205. /**
  34206. * Tries to copy an object by duplicating every property
  34207. * @param source defines the source object
  34208. * @param destination defines the target object
  34209. * @param doNotCopyList defines a list of properties to avoid
  34210. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34211. */
  34212. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34213. /**
  34214. * Gets a boolean indicating if the given object has no own property
  34215. * @param obj defines the object to test
  34216. * @returns true if object has no own property
  34217. */
  34218. static IsEmpty(obj: any): boolean;
  34219. /**
  34220. * Function used to register events at window level
  34221. * @param windowElement defines the Window object to use
  34222. * @param events defines the events to register
  34223. */
  34224. static RegisterTopRootEvents(windowElement: Window, events: {
  34225. name: string;
  34226. handler: Nullable<(e: FocusEvent) => any>;
  34227. }[]): void;
  34228. /**
  34229. * Function used to unregister events from window level
  34230. * @param windowElement defines the Window object to use
  34231. * @param events defines the events to unregister
  34232. */
  34233. static UnregisterTopRootEvents(windowElement: Window, events: {
  34234. name: string;
  34235. handler: Nullable<(e: FocusEvent) => any>;
  34236. }[]): void;
  34237. /**
  34238. * @ignore
  34239. */
  34240. static _ScreenshotCanvas: HTMLCanvasElement;
  34241. /**
  34242. * Dumps the current bound framebuffer
  34243. * @param width defines the rendering width
  34244. * @param height defines the rendering height
  34245. * @param engine defines the hosting engine
  34246. * @param successCallback defines the callback triggered once the data are available
  34247. * @param mimeType defines the mime type of the result
  34248. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34249. */
  34250. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34251. /**
  34252. * Converts the canvas data to blob.
  34253. * This acts as a polyfill for browsers not supporting the to blob function.
  34254. * @param canvas Defines the canvas to extract the data from
  34255. * @param successCallback Defines the callback triggered once the data are available
  34256. * @param mimeType Defines the mime type of the result
  34257. */
  34258. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34259. /**
  34260. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34261. * @param successCallback defines the callback triggered once the data are available
  34262. * @param mimeType defines the mime type of the result
  34263. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34264. */
  34265. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34266. /**
  34267. * Downloads a blob in the browser
  34268. * @param blob defines the blob to download
  34269. * @param fileName defines the name of the downloaded file
  34270. */
  34271. static Download(blob: Blob, fileName: string): void;
  34272. /**
  34273. * Captures a screenshot of the current rendering
  34274. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34275. * @param engine defines the rendering engine
  34276. * @param camera defines the source camera
  34277. * @param size This parameter can be set to a single number or to an object with the
  34278. * following (optional) properties: precision, width, height. If a single number is passed,
  34279. * it will be used for both width and height. If an object is passed, the screenshot size
  34280. * will be derived from the parameters. The precision property is a multiplier allowing
  34281. * rendering at a higher or lower resolution
  34282. * @param successCallback defines the callback receives a single parameter which contains the
  34283. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34284. * src parameter of an <img> to display it
  34285. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34286. * Check your browser for supported MIME types
  34287. */
  34288. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34289. /**
  34290. * Captures a screenshot of the current rendering
  34291. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34292. * @param engine defines the rendering engine
  34293. * @param camera defines the source camera
  34294. * @param size This parameter can be set to a single number or to an object with the
  34295. * following (optional) properties: precision, width, height. If a single number is passed,
  34296. * it will be used for both width and height. If an object is passed, the screenshot size
  34297. * will be derived from the parameters. The precision property is a multiplier allowing
  34298. * rendering at a higher or lower resolution
  34299. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34300. * Check your browser for supported MIME types
  34301. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34302. * to the src parameter of an <img> to display it
  34303. */
  34304. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34305. /**
  34306. * Generates an image screenshot from the specified camera.
  34307. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34308. * @param engine The engine to use for rendering
  34309. * @param camera The camera to use for rendering
  34310. * @param size This parameter can be set to a single number or to an object with the
  34311. * following (optional) properties: precision, width, height. If a single number is passed,
  34312. * it will be used for both width and height. If an object is passed, the screenshot size
  34313. * will be derived from the parameters. The precision property is a multiplier allowing
  34314. * rendering at a higher or lower resolution
  34315. * @param successCallback The callback receives a single parameter which contains the
  34316. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34317. * src parameter of an <img> to display it
  34318. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34319. * Check your browser for supported MIME types
  34320. * @param samples Texture samples (default: 1)
  34321. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34322. * @param fileName A name for for the downloaded file.
  34323. */
  34324. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34325. /**
  34326. * Generates an image screenshot from the specified camera.
  34327. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34328. * @param engine The engine to use for rendering
  34329. * @param camera The camera to use for rendering
  34330. * @param size This parameter can be set to a single number or to an object with the
  34331. * following (optional) properties: precision, width, height. If a single number is passed,
  34332. * it will be used for both width and height. If an object is passed, the screenshot size
  34333. * will be derived from the parameters. The precision property is a multiplier allowing
  34334. * rendering at a higher or lower resolution
  34335. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34336. * Check your browser for supported MIME types
  34337. * @param samples Texture samples (default: 1)
  34338. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34339. * @param fileName A name for for the downloaded file.
  34340. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34341. * to the src parameter of an <img> to display it
  34342. */
  34343. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34344. /**
  34345. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34346. * Be aware Math.random() could cause collisions, but:
  34347. * "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"
  34348. * @returns a pseudo random id
  34349. */
  34350. static RandomId(): string;
  34351. /**
  34352. * Test if the given uri is a base64 string
  34353. * @param uri The uri to test
  34354. * @return True if the uri is a base64 string or false otherwise
  34355. */
  34356. static IsBase64(uri: string): boolean;
  34357. /**
  34358. * Decode the given base64 uri.
  34359. * @param uri The uri to decode
  34360. * @return The decoded base64 data.
  34361. */
  34362. static DecodeBase64(uri: string): ArrayBuffer;
  34363. /**
  34364. * Gets the absolute url.
  34365. * @param url the input url
  34366. * @return the absolute url
  34367. */
  34368. static GetAbsoluteUrl(url: string): string;
  34369. /**
  34370. * No log
  34371. */
  34372. static readonly NoneLogLevel: number;
  34373. /**
  34374. * Only message logs
  34375. */
  34376. static readonly MessageLogLevel: number;
  34377. /**
  34378. * Only warning logs
  34379. */
  34380. static readonly WarningLogLevel: number;
  34381. /**
  34382. * Only error logs
  34383. */
  34384. static readonly ErrorLogLevel: number;
  34385. /**
  34386. * All logs
  34387. */
  34388. static readonly AllLogLevel: number;
  34389. /**
  34390. * Gets a value indicating the number of loading errors
  34391. * @ignorenaming
  34392. */
  34393. static get errorsCount(): number;
  34394. /**
  34395. * Callback called when a new log is added
  34396. */
  34397. static OnNewCacheEntry: (entry: string) => void;
  34398. /**
  34399. * Log a message to the console
  34400. * @param message defines the message to log
  34401. */
  34402. static Log(message: string): void;
  34403. /**
  34404. * Write a warning message to the console
  34405. * @param message defines the message to log
  34406. */
  34407. static Warn(message: string): void;
  34408. /**
  34409. * Write an error message to the console
  34410. * @param message defines the message to log
  34411. */
  34412. static Error(message: string): void;
  34413. /**
  34414. * Gets current log cache (list of logs)
  34415. */
  34416. static get LogCache(): string;
  34417. /**
  34418. * Clears the log cache
  34419. */
  34420. static ClearLogCache(): void;
  34421. /**
  34422. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34423. */
  34424. static set LogLevels(level: number);
  34425. /**
  34426. * Checks if the window object exists
  34427. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34428. */
  34429. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34430. /**
  34431. * No performance log
  34432. */
  34433. static readonly PerformanceNoneLogLevel: number;
  34434. /**
  34435. * Use user marks to log performance
  34436. */
  34437. static readonly PerformanceUserMarkLogLevel: number;
  34438. /**
  34439. * Log performance to the console
  34440. */
  34441. static readonly PerformanceConsoleLogLevel: number;
  34442. private static _performance;
  34443. /**
  34444. * Sets the current performance log level
  34445. */
  34446. static set PerformanceLogLevel(level: number);
  34447. private static _StartPerformanceCounterDisabled;
  34448. private static _EndPerformanceCounterDisabled;
  34449. private static _StartUserMark;
  34450. private static _EndUserMark;
  34451. private static _StartPerformanceConsole;
  34452. private static _EndPerformanceConsole;
  34453. /**
  34454. * Starts a performance counter
  34455. */
  34456. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34457. /**
  34458. * Ends a specific performance coutner
  34459. */
  34460. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34461. /**
  34462. * Gets either window.performance.now() if supported or Date.now() else
  34463. */
  34464. static get Now(): number;
  34465. /**
  34466. * This method will return the name of the class used to create the instance of the given object.
  34467. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34468. * @param object the object to get the class name from
  34469. * @param isType defines if the object is actually a type
  34470. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34471. */
  34472. static GetClassName(object: any, isType?: boolean): string;
  34473. /**
  34474. * Gets the first element of an array satisfying a given predicate
  34475. * @param array defines the array to browse
  34476. * @param predicate defines the predicate to use
  34477. * @returns null if not found or the element
  34478. */
  34479. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34480. /**
  34481. * This method will return the name of the full name of the class, including its owning module (if any).
  34482. * 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).
  34483. * @param object the object to get the class name from
  34484. * @param isType defines if the object is actually a type
  34485. * @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.
  34486. * @ignorenaming
  34487. */
  34488. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34489. /**
  34490. * Returns a promise that resolves after the given amount of time.
  34491. * @param delay Number of milliseconds to delay
  34492. * @returns Promise that resolves after the given amount of time
  34493. */
  34494. static DelayAsync(delay: number): Promise<void>;
  34495. /**
  34496. * Utility function to detect if the current user agent is Safari
  34497. * @returns whether or not the current user agent is safari
  34498. */
  34499. static IsSafari(): boolean;
  34500. }
  34501. /**
  34502. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34503. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34504. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34505. * @param name The name of the class, case should be preserved
  34506. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34507. */
  34508. export function className(name: string, module?: string): (target: Object) => void;
  34509. /**
  34510. * An implementation of a loop for asynchronous functions.
  34511. */
  34512. export class AsyncLoop {
  34513. /**
  34514. * Defines the number of iterations for the loop
  34515. */
  34516. iterations: number;
  34517. /**
  34518. * Defines the current index of the loop.
  34519. */
  34520. index: number;
  34521. private _done;
  34522. private _fn;
  34523. private _successCallback;
  34524. /**
  34525. * Constructor.
  34526. * @param iterations the number of iterations.
  34527. * @param func the function to run each iteration
  34528. * @param successCallback the callback that will be called upon succesful execution
  34529. * @param offset starting offset.
  34530. */
  34531. constructor(
  34532. /**
  34533. * Defines the number of iterations for the loop
  34534. */
  34535. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34536. /**
  34537. * Execute the next iteration. Must be called after the last iteration was finished.
  34538. */
  34539. executeNext(): void;
  34540. /**
  34541. * Break the loop and run the success callback.
  34542. */
  34543. breakLoop(): void;
  34544. /**
  34545. * Create and run an async loop.
  34546. * @param iterations the number of iterations.
  34547. * @param fn the function to run each iteration
  34548. * @param successCallback the callback that will be called upon succesful execution
  34549. * @param offset starting offset.
  34550. * @returns the created async loop object
  34551. */
  34552. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34553. /**
  34554. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34555. * @param iterations total number of iterations
  34556. * @param syncedIterations number of synchronous iterations in each async iteration.
  34557. * @param fn the function to call each iteration.
  34558. * @param callback a success call back that will be called when iterating stops.
  34559. * @param breakFunction a break condition (optional)
  34560. * @param timeout timeout settings for the setTimeout function. default - 0.
  34561. * @returns the created async loop object
  34562. */
  34563. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34564. }
  34565. }
  34566. declare module BABYLON {
  34567. /**
  34568. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34569. * The underlying implementation relies on an associative array to ensure the best performances.
  34570. * The value can be anything including 'null' but except 'undefined'
  34571. */
  34572. export class StringDictionary<T> {
  34573. /**
  34574. * This will clear this dictionary and copy the content from the 'source' one.
  34575. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34576. * @param source the dictionary to take the content from and copy to this dictionary
  34577. */
  34578. copyFrom(source: StringDictionary<T>): void;
  34579. /**
  34580. * Get a value based from its key
  34581. * @param key the given key to get the matching value from
  34582. * @return the value if found, otherwise undefined is returned
  34583. */
  34584. get(key: string): T | undefined;
  34585. /**
  34586. * Get a value from its key or add it if it doesn't exist.
  34587. * This method will ensure you that a given key/data will be present in the dictionary.
  34588. * @param key the given key to get the matching value from
  34589. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34590. * The factory will only be invoked if there's no data for the given key.
  34591. * @return the value corresponding to the key.
  34592. */
  34593. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34594. /**
  34595. * Get a value from its key if present in the dictionary otherwise add it
  34596. * @param key the key to get the value from
  34597. * @param val if there's no such key/value pair in the dictionary add it with this value
  34598. * @return the value corresponding to the key
  34599. */
  34600. getOrAdd(key: string, val: T): T;
  34601. /**
  34602. * Check if there's a given key in the dictionary
  34603. * @param key the key to check for
  34604. * @return true if the key is present, false otherwise
  34605. */
  34606. contains(key: string): boolean;
  34607. /**
  34608. * Add a new key and its corresponding value
  34609. * @param key the key to add
  34610. * @param value the value corresponding to the key
  34611. * @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
  34612. */
  34613. add(key: string, value: T): boolean;
  34614. /**
  34615. * Update a specific value associated to a key
  34616. * @param key defines the key to use
  34617. * @param value defines the value to store
  34618. * @returns true if the value was updated (or false if the key was not found)
  34619. */
  34620. set(key: string, value: T): boolean;
  34621. /**
  34622. * Get the element of the given key and remove it from the dictionary
  34623. * @param key defines the key to search
  34624. * @returns the value associated with the key or null if not found
  34625. */
  34626. getAndRemove(key: string): Nullable<T>;
  34627. /**
  34628. * Remove a key/value from the dictionary.
  34629. * @param key the key to remove
  34630. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34631. */
  34632. remove(key: string): boolean;
  34633. /**
  34634. * Clear the whole content of the dictionary
  34635. */
  34636. clear(): void;
  34637. /**
  34638. * Gets the current count
  34639. */
  34640. get count(): number;
  34641. /**
  34642. * Execute a callback on each key/val of the dictionary.
  34643. * Note that you can remove any element in this dictionary in the callback implementation
  34644. * @param callback the callback to execute on a given key/value pair
  34645. */
  34646. forEach(callback: (key: string, val: T) => void): void;
  34647. /**
  34648. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34649. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34650. * Note that you can remove any element in this dictionary in the callback implementation
  34651. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34652. * @returns the first item
  34653. */
  34654. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34655. private _count;
  34656. private _data;
  34657. }
  34658. }
  34659. declare module BABYLON {
  34660. /** @hidden */
  34661. export interface ICollisionCoordinator {
  34662. createCollider(): Collider;
  34663. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34664. init(scene: Scene): void;
  34665. }
  34666. /** @hidden */
  34667. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34668. private _scene;
  34669. private _scaledPosition;
  34670. private _scaledVelocity;
  34671. private _finalPosition;
  34672. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34673. createCollider(): Collider;
  34674. init(scene: Scene): void;
  34675. private _collideWithWorld;
  34676. }
  34677. }
  34678. declare module BABYLON {
  34679. /**
  34680. * Class used to manage all inputs for the scene.
  34681. */
  34682. export class InputManager {
  34683. /** The distance in pixel that you have to move to prevent some events */
  34684. static DragMovementThreshold: number;
  34685. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34686. static LongPressDelay: number;
  34687. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34688. static DoubleClickDelay: number;
  34689. /** If you need to check double click without raising a single click at first click, enable this flag */
  34690. static ExclusiveDoubleClickMode: boolean;
  34691. private _wheelEventName;
  34692. private _onPointerMove;
  34693. private _onPointerDown;
  34694. private _onPointerUp;
  34695. private _initClickEvent;
  34696. private _initActionManager;
  34697. private _delayedSimpleClick;
  34698. private _delayedSimpleClickTimeout;
  34699. private _previousDelayedSimpleClickTimeout;
  34700. private _meshPickProceed;
  34701. private _previousButtonPressed;
  34702. private _currentPickResult;
  34703. private _previousPickResult;
  34704. private _totalPointersPressed;
  34705. private _doubleClickOccured;
  34706. private _pointerOverMesh;
  34707. private _pickedDownMesh;
  34708. private _pickedUpMesh;
  34709. private _pointerX;
  34710. private _pointerY;
  34711. private _unTranslatedPointerX;
  34712. private _unTranslatedPointerY;
  34713. private _startingPointerPosition;
  34714. private _previousStartingPointerPosition;
  34715. private _startingPointerTime;
  34716. private _previousStartingPointerTime;
  34717. private _pointerCaptures;
  34718. private _onKeyDown;
  34719. private _onKeyUp;
  34720. private _onCanvasFocusObserver;
  34721. private _onCanvasBlurObserver;
  34722. private _scene;
  34723. /**
  34724. * Creates a new InputManager
  34725. * @param scene defines the hosting scene
  34726. */
  34727. constructor(scene: Scene);
  34728. /**
  34729. * Gets the mesh that is currently under the pointer
  34730. */
  34731. get meshUnderPointer(): Nullable<AbstractMesh>;
  34732. /**
  34733. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34734. */
  34735. get unTranslatedPointer(): Vector2;
  34736. /**
  34737. * Gets or sets the current on-screen X position of the pointer
  34738. */
  34739. get pointerX(): number;
  34740. set pointerX(value: number);
  34741. /**
  34742. * Gets or sets the current on-screen Y position of the pointer
  34743. */
  34744. get pointerY(): number;
  34745. set pointerY(value: number);
  34746. private _updatePointerPosition;
  34747. private _processPointerMove;
  34748. private _setRayOnPointerInfo;
  34749. private _checkPrePointerObservable;
  34750. /**
  34751. * Use this method to simulate a pointer move on a mesh
  34752. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34753. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34754. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34755. */
  34756. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34757. /**
  34758. * Use this method to simulate a pointer down on a mesh
  34759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34762. */
  34763. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34764. private _processPointerDown;
  34765. /** @hidden */
  34766. _isPointerSwiping(): boolean;
  34767. /**
  34768. * Use this method to simulate a pointer up on a mesh
  34769. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34770. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34771. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34772. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34773. */
  34774. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34775. private _processPointerUp;
  34776. /**
  34777. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34778. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34779. * @returns true if the pointer was captured
  34780. */
  34781. isPointerCaptured(pointerId?: number): boolean;
  34782. /**
  34783. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34784. * @param attachUp defines if you want to attach events to pointerup
  34785. * @param attachDown defines if you want to attach events to pointerdown
  34786. * @param attachMove defines if you want to attach events to pointermove
  34787. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34788. */
  34789. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34790. /**
  34791. * Detaches all event handlers
  34792. */
  34793. detachControl(): void;
  34794. /**
  34795. * Force the value of meshUnderPointer
  34796. * @param mesh defines the mesh to use
  34797. */
  34798. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34799. /**
  34800. * Gets the mesh under the pointer
  34801. * @returns a Mesh or null if no mesh is under the pointer
  34802. */
  34803. getPointerOverMesh(): Nullable<AbstractMesh>;
  34804. }
  34805. }
  34806. declare module BABYLON {
  34807. /**
  34808. * Helper class used to generate session unique ID
  34809. */
  34810. export class UniqueIdGenerator {
  34811. private static _UniqueIdCounter;
  34812. /**
  34813. * Gets an unique (relatively to the current scene) Id
  34814. */
  34815. static get UniqueId(): number;
  34816. }
  34817. }
  34818. declare module BABYLON {
  34819. /**
  34820. * This class defines the direct association between an animation and a target
  34821. */
  34822. export class TargetedAnimation {
  34823. /**
  34824. * Animation to perform
  34825. */
  34826. animation: Animation;
  34827. /**
  34828. * Target to animate
  34829. */
  34830. target: any;
  34831. /**
  34832. * Serialize the object
  34833. * @returns the JSON object representing the current entity
  34834. */
  34835. serialize(): any;
  34836. }
  34837. /**
  34838. * Use this class to create coordinated animations on multiple targets
  34839. */
  34840. export class AnimationGroup implements IDisposable {
  34841. /** The name of the animation group */
  34842. name: string;
  34843. private _scene;
  34844. private _targetedAnimations;
  34845. private _animatables;
  34846. private _from;
  34847. private _to;
  34848. private _isStarted;
  34849. private _isPaused;
  34850. private _speedRatio;
  34851. private _loopAnimation;
  34852. /**
  34853. * Gets or sets the unique id of the node
  34854. */
  34855. uniqueId: number;
  34856. /**
  34857. * This observable will notify when one animation have ended
  34858. */
  34859. onAnimationEndObservable: Observable<TargetedAnimation>;
  34860. /**
  34861. * Observer raised when one animation loops
  34862. */
  34863. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34864. /**
  34865. * Observer raised when all animations have looped
  34866. */
  34867. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34868. /**
  34869. * This observable will notify when all animations have ended.
  34870. */
  34871. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34872. /**
  34873. * This observable will notify when all animations have paused.
  34874. */
  34875. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34876. /**
  34877. * This observable will notify when all animations are playing.
  34878. */
  34879. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34880. /**
  34881. * Gets the first frame
  34882. */
  34883. get from(): number;
  34884. /**
  34885. * Gets the last frame
  34886. */
  34887. get to(): number;
  34888. /**
  34889. * Define if the animations are started
  34890. */
  34891. get isStarted(): boolean;
  34892. /**
  34893. * Gets a value indicating that the current group is playing
  34894. */
  34895. get isPlaying(): boolean;
  34896. /**
  34897. * Gets or sets the speed ratio to use for all animations
  34898. */
  34899. get speedRatio(): number;
  34900. /**
  34901. * Gets or sets the speed ratio to use for all animations
  34902. */
  34903. set speedRatio(value: number);
  34904. /**
  34905. * Gets or sets if all animations should loop or not
  34906. */
  34907. get loopAnimation(): boolean;
  34908. set loopAnimation(value: boolean);
  34909. /**
  34910. * Gets the targeted animations for this animation group
  34911. */
  34912. get targetedAnimations(): Array<TargetedAnimation>;
  34913. /**
  34914. * returning the list of animatables controlled by this animation group.
  34915. */
  34916. get animatables(): Array<Animatable>;
  34917. /**
  34918. * Instantiates a new Animation Group.
  34919. * This helps managing several animations at once.
  34920. * @see http://doc.babylonjs.com/how_to/group
  34921. * @param name Defines the name of the group
  34922. * @param scene Defines the scene the group belongs to
  34923. */
  34924. constructor(
  34925. /** The name of the animation group */
  34926. name: string, scene?: Nullable<Scene>);
  34927. /**
  34928. * Add an animation (with its target) in the group
  34929. * @param animation defines the animation we want to add
  34930. * @param target defines the target of the animation
  34931. * @returns the TargetedAnimation object
  34932. */
  34933. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34934. /**
  34935. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34936. * It can add constant keys at begin or end
  34937. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34938. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34939. * @returns the animation group
  34940. */
  34941. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34942. private _animationLoopCount;
  34943. private _animationLoopFlags;
  34944. private _processLoop;
  34945. /**
  34946. * Start all animations on given targets
  34947. * @param loop defines if animations must loop
  34948. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34949. * @param from defines the from key (optional)
  34950. * @param to defines the to key (optional)
  34951. * @returns the current animation group
  34952. */
  34953. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34954. /**
  34955. * Pause all animations
  34956. * @returns the animation group
  34957. */
  34958. pause(): AnimationGroup;
  34959. /**
  34960. * Play all animations to initial state
  34961. * This function will start() the animations if they were not started or will restart() them if they were paused
  34962. * @param loop defines if animations must loop
  34963. * @returns the animation group
  34964. */
  34965. play(loop?: boolean): AnimationGroup;
  34966. /**
  34967. * Reset all animations to initial state
  34968. * @returns the animation group
  34969. */
  34970. reset(): AnimationGroup;
  34971. /**
  34972. * Restart animations from key 0
  34973. * @returns the animation group
  34974. */
  34975. restart(): AnimationGroup;
  34976. /**
  34977. * Stop all animations
  34978. * @returns the animation group
  34979. */
  34980. stop(): AnimationGroup;
  34981. /**
  34982. * Set animation weight for all animatables
  34983. * @param weight defines the weight to use
  34984. * @return the animationGroup
  34985. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34986. */
  34987. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34988. /**
  34989. * Synchronize and normalize all animatables with a source animatable
  34990. * @param root defines the root animatable to synchronize with
  34991. * @return the animationGroup
  34992. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34993. */
  34994. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34995. /**
  34996. * Goes to a specific frame in this animation group
  34997. * @param frame the frame number to go to
  34998. * @return the animationGroup
  34999. */
  35000. goToFrame(frame: number): AnimationGroup;
  35001. /**
  35002. * Dispose all associated resources
  35003. */
  35004. dispose(): void;
  35005. private _checkAnimationGroupEnded;
  35006. /**
  35007. * Clone the current animation group and returns a copy
  35008. * @param newName defines the name of the new group
  35009. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35010. * @returns the new aniamtion group
  35011. */
  35012. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35013. /**
  35014. * Serializes the animationGroup to an object
  35015. * @returns Serialized object
  35016. */
  35017. serialize(): any;
  35018. /**
  35019. * Returns a new AnimationGroup object parsed from the source provided.
  35020. * @param parsedAnimationGroup defines the source
  35021. * @param scene defines the scene that will receive the animationGroup
  35022. * @returns a new AnimationGroup
  35023. */
  35024. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35025. /**
  35026. * Returns the string "AnimationGroup"
  35027. * @returns "AnimationGroup"
  35028. */
  35029. getClassName(): string;
  35030. /**
  35031. * Creates a detailled string about the object
  35032. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35033. * @returns a string representing the object
  35034. */
  35035. toString(fullDetails?: boolean): string;
  35036. }
  35037. }
  35038. declare module BABYLON {
  35039. /**
  35040. * Define an interface for all classes that will hold resources
  35041. */
  35042. export interface IDisposable {
  35043. /**
  35044. * Releases all held resources
  35045. */
  35046. dispose(): void;
  35047. }
  35048. /** Interface defining initialization parameters for Scene class */
  35049. export interface SceneOptions {
  35050. /**
  35051. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35052. * It will improve performance when the number of geometries becomes important.
  35053. */
  35054. useGeometryUniqueIdsMap?: boolean;
  35055. /**
  35056. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35057. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35058. */
  35059. useMaterialMeshMap?: boolean;
  35060. /**
  35061. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35062. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35063. */
  35064. useClonedMeshMap?: boolean;
  35065. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35066. virtual?: boolean;
  35067. }
  35068. /**
  35069. * Represents a scene to be rendered by the engine.
  35070. * @see http://doc.babylonjs.com/features/scene
  35071. */
  35072. export class Scene extends AbstractScene implements IAnimatable {
  35073. /** The fog is deactivated */
  35074. static readonly FOGMODE_NONE: number;
  35075. /** The fog density is following an exponential function */
  35076. static readonly FOGMODE_EXP: number;
  35077. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35078. static readonly FOGMODE_EXP2: number;
  35079. /** The fog density is following a linear function. */
  35080. static readonly FOGMODE_LINEAR: number;
  35081. /**
  35082. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35083. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35084. */
  35085. static MinDeltaTime: number;
  35086. /**
  35087. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35088. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35089. */
  35090. static MaxDeltaTime: number;
  35091. /**
  35092. * Factory used to create the default material.
  35093. * @param name The name of the material to create
  35094. * @param scene The scene to create the material for
  35095. * @returns The default material
  35096. */
  35097. static DefaultMaterialFactory(scene: Scene): Material;
  35098. /**
  35099. * Factory used to create the a collision coordinator.
  35100. * @returns The collision coordinator
  35101. */
  35102. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35103. /** @hidden */
  35104. _inputManager: InputManager;
  35105. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35106. cameraToUseForPointers: Nullable<Camera>;
  35107. /** @hidden */
  35108. readonly _isScene: boolean;
  35109. /** @hidden */
  35110. _blockEntityCollection: boolean;
  35111. /**
  35112. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35113. */
  35114. autoClear: boolean;
  35115. /**
  35116. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35117. */
  35118. autoClearDepthAndStencil: boolean;
  35119. /**
  35120. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35121. */
  35122. clearColor: Color4;
  35123. /**
  35124. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35125. */
  35126. ambientColor: Color3;
  35127. /**
  35128. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35129. * It should only be one of the following (if not the default embedded one):
  35130. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35131. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35132. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35133. * The material properties need to be setup according to the type of texture in use.
  35134. */
  35135. environmentBRDFTexture: BaseTexture;
  35136. /** @hidden */
  35137. protected _environmentTexture: Nullable<BaseTexture>;
  35138. /**
  35139. * Texture used in all pbr material as the reflection texture.
  35140. * As in the majority of the scene they are the same (exception for multi room and so on),
  35141. * this is easier to reference from here than from all the materials.
  35142. */
  35143. get environmentTexture(): Nullable<BaseTexture>;
  35144. /**
  35145. * Texture used in all pbr material as the reflection texture.
  35146. * As in the majority of the scene they are the same (exception for multi room and so on),
  35147. * this is easier to set here than in all the materials.
  35148. */
  35149. set environmentTexture(value: Nullable<BaseTexture>);
  35150. /** @hidden */
  35151. protected _environmentIntensity: number;
  35152. /**
  35153. * Intensity of the environment in all pbr material.
  35154. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35155. * As in the majority of the scene they are the same (exception for multi room and so on),
  35156. * this is easier to reference from here than from all the materials.
  35157. */
  35158. get environmentIntensity(): number;
  35159. /**
  35160. * Intensity of the environment in all pbr material.
  35161. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35162. * As in the majority of the scene they are the same (exception for multi room and so on),
  35163. * this is easier to set here than in all the materials.
  35164. */
  35165. set environmentIntensity(value: number);
  35166. /** @hidden */
  35167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35168. /**
  35169. * Default image processing configuration used either in the rendering
  35170. * Forward main pass or through the imageProcessingPostProcess if present.
  35171. * As in the majority of the scene they are the same (exception for multi camera),
  35172. * this is easier to reference from here than from all the materials and post process.
  35173. *
  35174. * No setter as we it is a shared configuration, you can set the values instead.
  35175. */
  35176. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35177. private _forceWireframe;
  35178. /**
  35179. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35180. */
  35181. set forceWireframe(value: boolean);
  35182. get forceWireframe(): boolean;
  35183. private _skipFrustumClipping;
  35184. /**
  35185. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35186. */
  35187. set skipFrustumClipping(value: boolean);
  35188. get skipFrustumClipping(): boolean;
  35189. private _forcePointsCloud;
  35190. /**
  35191. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35192. */
  35193. set forcePointsCloud(value: boolean);
  35194. get forcePointsCloud(): boolean;
  35195. /**
  35196. * Gets or sets the active clipplane 1
  35197. */
  35198. clipPlane: Nullable<Plane>;
  35199. /**
  35200. * Gets or sets the active clipplane 2
  35201. */
  35202. clipPlane2: Nullable<Plane>;
  35203. /**
  35204. * Gets or sets the active clipplane 3
  35205. */
  35206. clipPlane3: Nullable<Plane>;
  35207. /**
  35208. * Gets or sets the active clipplane 4
  35209. */
  35210. clipPlane4: Nullable<Plane>;
  35211. /**
  35212. * Gets or sets the active clipplane 5
  35213. */
  35214. clipPlane5: Nullable<Plane>;
  35215. /**
  35216. * Gets or sets the active clipplane 6
  35217. */
  35218. clipPlane6: Nullable<Plane>;
  35219. /**
  35220. * Gets or sets a boolean indicating if animations are enabled
  35221. */
  35222. animationsEnabled: boolean;
  35223. private _animationPropertiesOverride;
  35224. /**
  35225. * Gets or sets the animation properties override
  35226. */
  35227. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35228. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35229. /**
  35230. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35231. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35232. */
  35233. useConstantAnimationDeltaTime: boolean;
  35234. /**
  35235. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35236. * Please note that it requires to run a ray cast through the scene on every frame
  35237. */
  35238. constantlyUpdateMeshUnderPointer: boolean;
  35239. /**
  35240. * Defines the HTML cursor to use when hovering over interactive elements
  35241. */
  35242. hoverCursor: string;
  35243. /**
  35244. * Defines the HTML default cursor to use (empty by default)
  35245. */
  35246. defaultCursor: string;
  35247. /**
  35248. * Defines whether cursors are handled by the scene.
  35249. */
  35250. doNotHandleCursors: boolean;
  35251. /**
  35252. * This is used to call preventDefault() on pointer down
  35253. * in order to block unwanted artifacts like system double clicks
  35254. */
  35255. preventDefaultOnPointerDown: boolean;
  35256. /**
  35257. * This is used to call preventDefault() on pointer up
  35258. * in order to block unwanted artifacts like system double clicks
  35259. */
  35260. preventDefaultOnPointerUp: boolean;
  35261. /**
  35262. * Gets or sets user defined metadata
  35263. */
  35264. metadata: any;
  35265. /**
  35266. * For internal use only. Please do not use.
  35267. */
  35268. reservedDataStore: any;
  35269. /**
  35270. * Gets the name of the plugin used to load this scene (null by default)
  35271. */
  35272. loadingPluginName: string;
  35273. /**
  35274. * Use this array to add regular expressions used to disable offline support for specific urls
  35275. */
  35276. disableOfflineSupportExceptionRules: RegExp[];
  35277. /**
  35278. * An event triggered when the scene is disposed.
  35279. */
  35280. onDisposeObservable: Observable<Scene>;
  35281. private _onDisposeObserver;
  35282. /** Sets a function to be executed when this scene is disposed. */
  35283. set onDispose(callback: () => void);
  35284. /**
  35285. * An event triggered before rendering the scene (right after animations and physics)
  35286. */
  35287. onBeforeRenderObservable: Observable<Scene>;
  35288. private _onBeforeRenderObserver;
  35289. /** Sets a function to be executed before rendering this scene */
  35290. set beforeRender(callback: Nullable<() => void>);
  35291. /**
  35292. * An event triggered after rendering the scene
  35293. */
  35294. onAfterRenderObservable: Observable<Scene>;
  35295. /**
  35296. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35297. */
  35298. onAfterRenderCameraObservable: Observable<Camera>;
  35299. private _onAfterRenderObserver;
  35300. /** Sets a function to be executed after rendering this scene */
  35301. set afterRender(callback: Nullable<() => void>);
  35302. /**
  35303. * An event triggered before animating the scene
  35304. */
  35305. onBeforeAnimationsObservable: Observable<Scene>;
  35306. /**
  35307. * An event triggered after animations processing
  35308. */
  35309. onAfterAnimationsObservable: Observable<Scene>;
  35310. /**
  35311. * An event triggered before draw calls are ready to be sent
  35312. */
  35313. onBeforeDrawPhaseObservable: Observable<Scene>;
  35314. /**
  35315. * An event triggered after draw calls have been sent
  35316. */
  35317. onAfterDrawPhaseObservable: Observable<Scene>;
  35318. /**
  35319. * An event triggered when the scene is ready
  35320. */
  35321. onReadyObservable: Observable<Scene>;
  35322. /**
  35323. * An event triggered before rendering a camera
  35324. */
  35325. onBeforeCameraRenderObservable: Observable<Camera>;
  35326. private _onBeforeCameraRenderObserver;
  35327. /** Sets a function to be executed before rendering a camera*/
  35328. set beforeCameraRender(callback: () => void);
  35329. /**
  35330. * An event triggered after rendering a camera
  35331. */
  35332. onAfterCameraRenderObservable: Observable<Camera>;
  35333. private _onAfterCameraRenderObserver;
  35334. /** Sets a function to be executed after rendering a camera*/
  35335. set afterCameraRender(callback: () => void);
  35336. /**
  35337. * An event triggered when active meshes evaluation is about to start
  35338. */
  35339. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35340. /**
  35341. * An event triggered when active meshes evaluation is done
  35342. */
  35343. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35344. /**
  35345. * An event triggered when particles rendering is about to start
  35346. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35347. */
  35348. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35349. /**
  35350. * An event triggered when particles rendering is done
  35351. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35352. */
  35353. onAfterParticlesRenderingObservable: Observable<Scene>;
  35354. /**
  35355. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35356. */
  35357. onDataLoadedObservable: Observable<Scene>;
  35358. /**
  35359. * An event triggered when a camera is created
  35360. */
  35361. onNewCameraAddedObservable: Observable<Camera>;
  35362. /**
  35363. * An event triggered when a camera is removed
  35364. */
  35365. onCameraRemovedObservable: Observable<Camera>;
  35366. /**
  35367. * An event triggered when a light is created
  35368. */
  35369. onNewLightAddedObservable: Observable<Light>;
  35370. /**
  35371. * An event triggered when a light is removed
  35372. */
  35373. onLightRemovedObservable: Observable<Light>;
  35374. /**
  35375. * An event triggered when a geometry is created
  35376. */
  35377. onNewGeometryAddedObservable: Observable<Geometry>;
  35378. /**
  35379. * An event triggered when a geometry is removed
  35380. */
  35381. onGeometryRemovedObservable: Observable<Geometry>;
  35382. /**
  35383. * An event triggered when a transform node is created
  35384. */
  35385. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35386. /**
  35387. * An event triggered when a transform node is removed
  35388. */
  35389. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35390. /**
  35391. * An event triggered when a mesh is created
  35392. */
  35393. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35394. /**
  35395. * An event triggered when a mesh is removed
  35396. */
  35397. onMeshRemovedObservable: Observable<AbstractMesh>;
  35398. /**
  35399. * An event triggered when a skeleton is created
  35400. */
  35401. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35402. /**
  35403. * An event triggered when a skeleton is removed
  35404. */
  35405. onSkeletonRemovedObservable: Observable<Skeleton>;
  35406. /**
  35407. * An event triggered when a material is created
  35408. */
  35409. onNewMaterialAddedObservable: Observable<Material>;
  35410. /**
  35411. * An event triggered when a material is removed
  35412. */
  35413. onMaterialRemovedObservable: Observable<Material>;
  35414. /**
  35415. * An event triggered when a texture is created
  35416. */
  35417. onNewTextureAddedObservable: Observable<BaseTexture>;
  35418. /**
  35419. * An event triggered when a texture is removed
  35420. */
  35421. onTextureRemovedObservable: Observable<BaseTexture>;
  35422. /**
  35423. * An event triggered when render targets are about to be rendered
  35424. * Can happen multiple times per frame.
  35425. */
  35426. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35427. /**
  35428. * An event triggered when render targets were rendered.
  35429. * Can happen multiple times per frame.
  35430. */
  35431. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35432. /**
  35433. * An event triggered before calculating deterministic simulation step
  35434. */
  35435. onBeforeStepObservable: Observable<Scene>;
  35436. /**
  35437. * An event triggered after calculating deterministic simulation step
  35438. */
  35439. onAfterStepObservable: Observable<Scene>;
  35440. /**
  35441. * An event triggered when the activeCamera property is updated
  35442. */
  35443. onActiveCameraChanged: Observable<Scene>;
  35444. /**
  35445. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35446. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35447. * 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)
  35448. */
  35449. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35450. /**
  35451. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35452. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35453. * 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)
  35454. */
  35455. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35456. /**
  35457. * This Observable will when a mesh has been imported into the scene.
  35458. */
  35459. onMeshImportedObservable: Observable<AbstractMesh>;
  35460. /**
  35461. * This Observable will when an animation file has been imported into the scene.
  35462. */
  35463. onAnimationFileImportedObservable: Observable<Scene>;
  35464. /**
  35465. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35466. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35467. */
  35468. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35469. /** @hidden */
  35470. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35471. /**
  35472. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35473. */
  35474. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35475. /**
  35476. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35477. */
  35478. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35479. /**
  35480. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35481. */
  35482. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35483. /** Callback called when a pointer move is detected */
  35484. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35485. /** Callback called when a pointer down is detected */
  35486. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35487. /** Callback called when a pointer up is detected */
  35488. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35489. /** Callback called when a pointer pick is detected */
  35490. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35491. /**
  35492. * 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).
  35493. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35494. */
  35495. onPrePointerObservable: Observable<PointerInfoPre>;
  35496. /**
  35497. * Observable event triggered each time an input event is received from the rendering canvas
  35498. */
  35499. onPointerObservable: Observable<PointerInfo>;
  35500. /**
  35501. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35502. */
  35503. get unTranslatedPointer(): Vector2;
  35504. /**
  35505. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35506. */
  35507. static get DragMovementThreshold(): number;
  35508. static set DragMovementThreshold(value: number);
  35509. /**
  35510. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35511. */
  35512. static get LongPressDelay(): number;
  35513. static set LongPressDelay(value: number);
  35514. /**
  35515. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35516. */
  35517. static get DoubleClickDelay(): number;
  35518. static set DoubleClickDelay(value: number);
  35519. /** If you need to check double click without raising a single click at first click, enable this flag */
  35520. static get ExclusiveDoubleClickMode(): boolean;
  35521. static set ExclusiveDoubleClickMode(value: boolean);
  35522. /** @hidden */
  35523. _mirroredCameraPosition: Nullable<Vector3>;
  35524. /**
  35525. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35526. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35527. */
  35528. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35529. /**
  35530. * Observable event triggered each time an keyboard event is received from the hosting window
  35531. */
  35532. onKeyboardObservable: Observable<KeyboardInfo>;
  35533. private _useRightHandedSystem;
  35534. /**
  35535. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35536. */
  35537. set useRightHandedSystem(value: boolean);
  35538. get useRightHandedSystem(): boolean;
  35539. private _timeAccumulator;
  35540. private _currentStepId;
  35541. private _currentInternalStep;
  35542. /**
  35543. * Sets the step Id used by deterministic lock step
  35544. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35545. * @param newStepId defines the step Id
  35546. */
  35547. setStepId(newStepId: number): void;
  35548. /**
  35549. * Gets the step Id used by deterministic lock step
  35550. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35551. * @returns the step Id
  35552. */
  35553. getStepId(): number;
  35554. /**
  35555. * Gets the internal step used by deterministic lock step
  35556. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35557. * @returns the internal step
  35558. */
  35559. getInternalStep(): number;
  35560. private _fogEnabled;
  35561. /**
  35562. * Gets or sets a boolean indicating if fog is enabled on this scene
  35563. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35564. * (Default is true)
  35565. */
  35566. set fogEnabled(value: boolean);
  35567. get fogEnabled(): boolean;
  35568. private _fogMode;
  35569. /**
  35570. * Gets or sets the fog mode to use
  35571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35572. * | mode | value |
  35573. * | --- | --- |
  35574. * | FOGMODE_NONE | 0 |
  35575. * | FOGMODE_EXP | 1 |
  35576. * | FOGMODE_EXP2 | 2 |
  35577. * | FOGMODE_LINEAR | 3 |
  35578. */
  35579. set fogMode(value: number);
  35580. get fogMode(): number;
  35581. /**
  35582. * Gets or sets the fog color to use
  35583. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35584. * (Default is Color3(0.2, 0.2, 0.3))
  35585. */
  35586. fogColor: Color3;
  35587. /**
  35588. * Gets or sets the fog density to use
  35589. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35590. * (Default is 0.1)
  35591. */
  35592. fogDensity: number;
  35593. /**
  35594. * Gets or sets the fog start distance to use
  35595. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35596. * (Default is 0)
  35597. */
  35598. fogStart: number;
  35599. /**
  35600. * Gets or sets the fog end distance to use
  35601. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35602. * (Default is 1000)
  35603. */
  35604. fogEnd: number;
  35605. private _shadowsEnabled;
  35606. /**
  35607. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35608. */
  35609. set shadowsEnabled(value: boolean);
  35610. get shadowsEnabled(): boolean;
  35611. private _lightsEnabled;
  35612. /**
  35613. * Gets or sets a boolean indicating if lights are enabled on this scene
  35614. */
  35615. set lightsEnabled(value: boolean);
  35616. get lightsEnabled(): boolean;
  35617. /** All of the active cameras added to this scene. */
  35618. activeCameras: Camera[];
  35619. /** @hidden */
  35620. _activeCamera: Nullable<Camera>;
  35621. /** Gets or sets the current active camera */
  35622. get activeCamera(): Nullable<Camera>;
  35623. set activeCamera(value: Nullable<Camera>);
  35624. private _defaultMaterial;
  35625. /** The default material used on meshes when no material is affected */
  35626. get defaultMaterial(): Material;
  35627. /** The default material used on meshes when no material is affected */
  35628. set defaultMaterial(value: Material);
  35629. private _texturesEnabled;
  35630. /**
  35631. * Gets or sets a boolean indicating if textures are enabled on this scene
  35632. */
  35633. set texturesEnabled(value: boolean);
  35634. get texturesEnabled(): boolean;
  35635. /**
  35636. * Gets or sets a boolean indicating if particles are enabled on this scene
  35637. */
  35638. particlesEnabled: boolean;
  35639. /**
  35640. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35641. */
  35642. spritesEnabled: boolean;
  35643. private _skeletonsEnabled;
  35644. /**
  35645. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35646. */
  35647. set skeletonsEnabled(value: boolean);
  35648. get skeletonsEnabled(): boolean;
  35649. /**
  35650. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35651. */
  35652. lensFlaresEnabled: boolean;
  35653. /**
  35654. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35656. */
  35657. collisionsEnabled: boolean;
  35658. private _collisionCoordinator;
  35659. /** @hidden */
  35660. get collisionCoordinator(): ICollisionCoordinator;
  35661. /**
  35662. * Defines the gravity applied to this scene (used only for collisions)
  35663. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35664. */
  35665. gravity: Vector3;
  35666. /**
  35667. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35668. */
  35669. postProcessesEnabled: boolean;
  35670. /**
  35671. * The list of postprocesses added to the scene
  35672. */
  35673. postProcesses: PostProcess[];
  35674. /**
  35675. * Gets the current postprocess manager
  35676. */
  35677. postProcessManager: PostProcessManager;
  35678. /**
  35679. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35680. */
  35681. renderTargetsEnabled: boolean;
  35682. /**
  35683. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35684. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35685. */
  35686. dumpNextRenderTargets: boolean;
  35687. /**
  35688. * The list of user defined render targets added to the scene
  35689. */
  35690. customRenderTargets: RenderTargetTexture[];
  35691. /**
  35692. * Defines if texture loading must be delayed
  35693. * If true, textures will only be loaded when they need to be rendered
  35694. */
  35695. useDelayedTextureLoading: boolean;
  35696. /**
  35697. * Gets the list of meshes imported to the scene through SceneLoader
  35698. */
  35699. importedMeshesFiles: String[];
  35700. /**
  35701. * Gets or sets a boolean indicating if probes are enabled on this scene
  35702. */
  35703. probesEnabled: boolean;
  35704. /**
  35705. * Gets or sets the current offline provider to use to store scene data
  35706. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35707. */
  35708. offlineProvider: IOfflineProvider;
  35709. /**
  35710. * Gets or sets the action manager associated with the scene
  35711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35712. */
  35713. actionManager: AbstractActionManager;
  35714. private _meshesForIntersections;
  35715. /**
  35716. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35717. */
  35718. proceduralTexturesEnabled: boolean;
  35719. private _engine;
  35720. private _totalVertices;
  35721. /** @hidden */
  35722. _activeIndices: PerfCounter;
  35723. /** @hidden */
  35724. _activeParticles: PerfCounter;
  35725. /** @hidden */
  35726. _activeBones: PerfCounter;
  35727. private _animationRatio;
  35728. /** @hidden */
  35729. _animationTimeLast: number;
  35730. /** @hidden */
  35731. _animationTime: number;
  35732. /**
  35733. * Gets or sets a general scale for animation speed
  35734. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35735. */
  35736. animationTimeScale: number;
  35737. /** @hidden */
  35738. _cachedMaterial: Nullable<Material>;
  35739. /** @hidden */
  35740. _cachedEffect: Nullable<Effect>;
  35741. /** @hidden */
  35742. _cachedVisibility: Nullable<number>;
  35743. private _renderId;
  35744. private _frameId;
  35745. private _executeWhenReadyTimeoutId;
  35746. private _intermediateRendering;
  35747. private _viewUpdateFlag;
  35748. private _projectionUpdateFlag;
  35749. /** @hidden */
  35750. _toBeDisposed: Nullable<IDisposable>[];
  35751. private _activeRequests;
  35752. /** @hidden */
  35753. _pendingData: any[];
  35754. private _isDisposed;
  35755. /**
  35756. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35757. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35758. */
  35759. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35760. private _activeMeshes;
  35761. private _processedMaterials;
  35762. private _renderTargets;
  35763. /** @hidden */
  35764. _activeParticleSystems: SmartArray<IParticleSystem>;
  35765. private _activeSkeletons;
  35766. private _softwareSkinnedMeshes;
  35767. private _renderingManager;
  35768. /** @hidden */
  35769. _activeAnimatables: Animatable[];
  35770. private _transformMatrix;
  35771. private _sceneUbo;
  35772. /** @hidden */
  35773. _viewMatrix: Matrix;
  35774. private _projectionMatrix;
  35775. /** @hidden */
  35776. _forcedViewPosition: Nullable<Vector3>;
  35777. /** @hidden */
  35778. _frustumPlanes: Plane[];
  35779. /**
  35780. * Gets the list of frustum planes (built from the active camera)
  35781. */
  35782. get frustumPlanes(): Plane[];
  35783. /**
  35784. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35785. * This is useful if there are more lights that the maximum simulteanous authorized
  35786. */
  35787. requireLightSorting: boolean;
  35788. /** @hidden */
  35789. readonly useMaterialMeshMap: boolean;
  35790. /** @hidden */
  35791. readonly useClonedMeshMap: boolean;
  35792. private _externalData;
  35793. private _uid;
  35794. /**
  35795. * @hidden
  35796. * Backing store of defined scene components.
  35797. */
  35798. _components: ISceneComponent[];
  35799. /**
  35800. * @hidden
  35801. * Backing store of defined scene components.
  35802. */
  35803. _serializableComponents: ISceneSerializableComponent[];
  35804. /**
  35805. * List of components to register on the next registration step.
  35806. */
  35807. private _transientComponents;
  35808. /**
  35809. * Registers the transient components if needed.
  35810. */
  35811. private _registerTransientComponents;
  35812. /**
  35813. * @hidden
  35814. * Add a component to the scene.
  35815. * Note that the ccomponent could be registered on th next frame if this is called after
  35816. * the register component stage.
  35817. * @param component Defines the component to add to the scene
  35818. */
  35819. _addComponent(component: ISceneComponent): void;
  35820. /**
  35821. * @hidden
  35822. * Gets a component from the scene.
  35823. * @param name defines the name of the component to retrieve
  35824. * @returns the component or null if not present
  35825. */
  35826. _getComponent(name: string): Nullable<ISceneComponent>;
  35827. /**
  35828. * @hidden
  35829. * Defines the actions happening before camera updates.
  35830. */
  35831. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35832. /**
  35833. * @hidden
  35834. * Defines the actions happening before clear the canvas.
  35835. */
  35836. _beforeClearStage: Stage<SimpleStageAction>;
  35837. /**
  35838. * @hidden
  35839. * Defines the actions when collecting render targets for the frame.
  35840. */
  35841. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35842. /**
  35843. * @hidden
  35844. * Defines the actions happening for one camera in the frame.
  35845. */
  35846. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35847. /**
  35848. * @hidden
  35849. * Defines the actions happening during the per mesh ready checks.
  35850. */
  35851. _isReadyForMeshStage: Stage<MeshStageAction>;
  35852. /**
  35853. * @hidden
  35854. * Defines the actions happening before evaluate active mesh checks.
  35855. */
  35856. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35857. /**
  35858. * @hidden
  35859. * Defines the actions happening during the evaluate sub mesh checks.
  35860. */
  35861. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35862. /**
  35863. * @hidden
  35864. * Defines the actions happening during the active mesh stage.
  35865. */
  35866. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35867. /**
  35868. * @hidden
  35869. * Defines the actions happening during the per camera render target step.
  35870. */
  35871. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35872. /**
  35873. * @hidden
  35874. * Defines the actions happening just before the active camera is drawing.
  35875. */
  35876. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35877. /**
  35878. * @hidden
  35879. * Defines the actions happening just before a render target is drawing.
  35880. */
  35881. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35882. /**
  35883. * @hidden
  35884. * Defines the actions happening just before a rendering group is drawing.
  35885. */
  35886. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35887. /**
  35888. * @hidden
  35889. * Defines the actions happening just before a mesh is drawing.
  35890. */
  35891. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35892. /**
  35893. * @hidden
  35894. * Defines the actions happening just after a mesh has been drawn.
  35895. */
  35896. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35897. /**
  35898. * @hidden
  35899. * Defines the actions happening just after a rendering group has been drawn.
  35900. */
  35901. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35902. /**
  35903. * @hidden
  35904. * Defines the actions happening just after the active camera has been drawn.
  35905. */
  35906. _afterCameraDrawStage: Stage<CameraStageAction>;
  35907. /**
  35908. * @hidden
  35909. * Defines the actions happening just after a render target has been drawn.
  35910. */
  35911. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35912. /**
  35913. * @hidden
  35914. * Defines the actions happening just after rendering all cameras and computing intersections.
  35915. */
  35916. _afterRenderStage: Stage<SimpleStageAction>;
  35917. /**
  35918. * @hidden
  35919. * Defines the actions happening when a pointer move event happens.
  35920. */
  35921. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35922. /**
  35923. * @hidden
  35924. * Defines the actions happening when a pointer down event happens.
  35925. */
  35926. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35927. /**
  35928. * @hidden
  35929. * Defines the actions happening when a pointer up event happens.
  35930. */
  35931. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35932. /**
  35933. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35934. */
  35935. private geometriesByUniqueId;
  35936. /**
  35937. * Creates a new Scene
  35938. * @param engine defines the engine to use to render this scene
  35939. * @param options defines the scene options
  35940. */
  35941. constructor(engine: Engine, options?: SceneOptions);
  35942. /**
  35943. * Gets a string idenfifying the name of the class
  35944. * @returns "Scene" string
  35945. */
  35946. getClassName(): string;
  35947. private _defaultMeshCandidates;
  35948. /**
  35949. * @hidden
  35950. */
  35951. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35952. private _defaultSubMeshCandidates;
  35953. /**
  35954. * @hidden
  35955. */
  35956. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35957. /**
  35958. * Sets the default candidate providers for the scene.
  35959. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35960. * and getCollidingSubMeshCandidates to their default function
  35961. */
  35962. setDefaultCandidateProviders(): void;
  35963. /**
  35964. * Gets the mesh that is currently under the pointer
  35965. */
  35966. get meshUnderPointer(): Nullable<AbstractMesh>;
  35967. /**
  35968. * Gets or sets the current on-screen X position of the pointer
  35969. */
  35970. get pointerX(): number;
  35971. set pointerX(value: number);
  35972. /**
  35973. * Gets or sets the current on-screen Y position of the pointer
  35974. */
  35975. get pointerY(): number;
  35976. set pointerY(value: number);
  35977. /**
  35978. * Gets the cached material (ie. the latest rendered one)
  35979. * @returns the cached material
  35980. */
  35981. getCachedMaterial(): Nullable<Material>;
  35982. /**
  35983. * Gets the cached effect (ie. the latest rendered one)
  35984. * @returns the cached effect
  35985. */
  35986. getCachedEffect(): Nullable<Effect>;
  35987. /**
  35988. * Gets the cached visibility state (ie. the latest rendered one)
  35989. * @returns the cached visibility state
  35990. */
  35991. getCachedVisibility(): Nullable<number>;
  35992. /**
  35993. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35994. * @param material defines the current material
  35995. * @param effect defines the current effect
  35996. * @param visibility defines the current visibility state
  35997. * @returns true if one parameter is not cached
  35998. */
  35999. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  36000. /**
  36001. * Gets the engine associated with the scene
  36002. * @returns an Engine
  36003. */
  36004. getEngine(): Engine;
  36005. /**
  36006. * Gets the total number of vertices rendered per frame
  36007. * @returns the total number of vertices rendered per frame
  36008. */
  36009. getTotalVertices(): number;
  36010. /**
  36011. * Gets the performance counter for total vertices
  36012. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36013. */
  36014. get totalVerticesPerfCounter(): PerfCounter;
  36015. /**
  36016. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36017. * @returns the total number of active indices rendered per frame
  36018. */
  36019. getActiveIndices(): number;
  36020. /**
  36021. * Gets the performance counter for active indices
  36022. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36023. */
  36024. get totalActiveIndicesPerfCounter(): PerfCounter;
  36025. /**
  36026. * Gets the total number of active particles rendered per frame
  36027. * @returns the total number of active particles rendered per frame
  36028. */
  36029. getActiveParticles(): number;
  36030. /**
  36031. * Gets the performance counter for active particles
  36032. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36033. */
  36034. get activeParticlesPerfCounter(): PerfCounter;
  36035. /**
  36036. * Gets the total number of active bones rendered per frame
  36037. * @returns the total number of active bones rendered per frame
  36038. */
  36039. getActiveBones(): number;
  36040. /**
  36041. * Gets the performance counter for active bones
  36042. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36043. */
  36044. get activeBonesPerfCounter(): PerfCounter;
  36045. /**
  36046. * Gets the array of active meshes
  36047. * @returns an array of AbstractMesh
  36048. */
  36049. getActiveMeshes(): SmartArray<AbstractMesh>;
  36050. /**
  36051. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36052. * @returns a number
  36053. */
  36054. getAnimationRatio(): number;
  36055. /**
  36056. * Gets an unique Id for the current render phase
  36057. * @returns a number
  36058. */
  36059. getRenderId(): number;
  36060. /**
  36061. * Gets an unique Id for the current frame
  36062. * @returns a number
  36063. */
  36064. getFrameId(): number;
  36065. /** Call this function if you want to manually increment the render Id*/
  36066. incrementRenderId(): void;
  36067. private _createUbo;
  36068. /**
  36069. * Use this method to simulate a pointer move on a mesh
  36070. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36071. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36072. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36073. * @returns the current scene
  36074. */
  36075. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36076. /**
  36077. * Use this method to simulate a pointer down on a mesh
  36078. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36079. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36080. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36081. * @returns the current scene
  36082. */
  36083. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36084. /**
  36085. * Use this method to simulate a pointer up on a mesh
  36086. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36087. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36088. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36089. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36090. * @returns the current scene
  36091. */
  36092. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36093. /**
  36094. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36095. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36096. * @returns true if the pointer was captured
  36097. */
  36098. isPointerCaptured(pointerId?: number): boolean;
  36099. /**
  36100. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36101. * @param attachUp defines if you want to attach events to pointerup
  36102. * @param attachDown defines if you want to attach events to pointerdown
  36103. * @param attachMove defines if you want to attach events to pointermove
  36104. */
  36105. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36106. /** Detaches all event handlers*/
  36107. detachControl(): void;
  36108. /**
  36109. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36110. * Delay loaded resources are not taking in account
  36111. * @return true if all required resources are ready
  36112. */
  36113. isReady(): boolean;
  36114. /** Resets all cached information relative to material (including effect and visibility) */
  36115. resetCachedMaterial(): void;
  36116. /**
  36117. * Registers a function to be called before every frame render
  36118. * @param func defines the function to register
  36119. */
  36120. registerBeforeRender(func: () => void): void;
  36121. /**
  36122. * Unregisters a function called before every frame render
  36123. * @param func defines the function to unregister
  36124. */
  36125. unregisterBeforeRender(func: () => void): void;
  36126. /**
  36127. * Registers a function to be called after every frame render
  36128. * @param func defines the function to register
  36129. */
  36130. registerAfterRender(func: () => void): void;
  36131. /**
  36132. * Unregisters a function called after every frame render
  36133. * @param func defines the function to unregister
  36134. */
  36135. unregisterAfterRender(func: () => void): void;
  36136. private _executeOnceBeforeRender;
  36137. /**
  36138. * The provided function will run before render once and will be disposed afterwards.
  36139. * A timeout delay can be provided so that the function will be executed in N ms.
  36140. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36141. * @param func The function to be executed.
  36142. * @param timeout optional delay in ms
  36143. */
  36144. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36145. /** @hidden */
  36146. _addPendingData(data: any): void;
  36147. /** @hidden */
  36148. _removePendingData(data: any): void;
  36149. /**
  36150. * Returns the number of items waiting to be loaded
  36151. * @returns the number of items waiting to be loaded
  36152. */
  36153. getWaitingItemsCount(): number;
  36154. /**
  36155. * Returns a boolean indicating if the scene is still loading data
  36156. */
  36157. get isLoading(): boolean;
  36158. /**
  36159. * Registers a function to be executed when the scene is ready
  36160. * @param {Function} func - the function to be executed
  36161. */
  36162. executeWhenReady(func: () => void): void;
  36163. /**
  36164. * Returns a promise that resolves when the scene is ready
  36165. * @returns A promise that resolves when the scene is ready
  36166. */
  36167. whenReadyAsync(): Promise<void>;
  36168. /** @hidden */
  36169. _checkIsReady(): void;
  36170. /**
  36171. * Gets all animatable attached to the scene
  36172. */
  36173. get animatables(): Animatable[];
  36174. /**
  36175. * Resets the last animation time frame.
  36176. * Useful to override when animations start running when loading a scene for the first time.
  36177. */
  36178. resetLastAnimationTimeFrame(): void;
  36179. /**
  36180. * Gets the current view matrix
  36181. * @returns a Matrix
  36182. */
  36183. getViewMatrix(): Matrix;
  36184. /**
  36185. * Gets the current projection matrix
  36186. * @returns a Matrix
  36187. */
  36188. getProjectionMatrix(): Matrix;
  36189. /**
  36190. * Gets the current transform matrix
  36191. * @returns a Matrix made of View * Projection
  36192. */
  36193. getTransformMatrix(): Matrix;
  36194. /**
  36195. * Sets the current transform matrix
  36196. * @param viewL defines the View matrix to use
  36197. * @param projectionL defines the Projection matrix to use
  36198. * @param viewR defines the right View matrix to use (if provided)
  36199. * @param projectionR defines the right Projection matrix to use (if provided)
  36200. */
  36201. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36202. /**
  36203. * Gets the uniform buffer used to store scene data
  36204. * @returns a UniformBuffer
  36205. */
  36206. getSceneUniformBuffer(): UniformBuffer;
  36207. /**
  36208. * Gets an unique (relatively to the current scene) Id
  36209. * @returns an unique number for the scene
  36210. */
  36211. getUniqueId(): number;
  36212. /**
  36213. * Add a mesh to the list of scene's meshes
  36214. * @param newMesh defines the mesh to add
  36215. * @param recursive if all child meshes should also be added to the scene
  36216. */
  36217. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36218. /**
  36219. * Remove a mesh for the list of scene's meshes
  36220. * @param toRemove defines the mesh to remove
  36221. * @param recursive if all child meshes should also be removed from the scene
  36222. * @returns the index where the mesh was in the mesh list
  36223. */
  36224. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36225. /**
  36226. * Add a transform node to the list of scene's transform nodes
  36227. * @param newTransformNode defines the transform node to add
  36228. */
  36229. addTransformNode(newTransformNode: TransformNode): void;
  36230. /**
  36231. * Remove a transform node for the list of scene's transform nodes
  36232. * @param toRemove defines the transform node to remove
  36233. * @returns the index where the transform node was in the transform node list
  36234. */
  36235. removeTransformNode(toRemove: TransformNode): number;
  36236. /**
  36237. * Remove a skeleton for the list of scene's skeletons
  36238. * @param toRemove defines the skeleton to remove
  36239. * @returns the index where the skeleton was in the skeleton list
  36240. */
  36241. removeSkeleton(toRemove: Skeleton): number;
  36242. /**
  36243. * Remove a morph target for the list of scene's morph targets
  36244. * @param toRemove defines the morph target to remove
  36245. * @returns the index where the morph target was in the morph target list
  36246. */
  36247. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36248. /**
  36249. * Remove a light for the list of scene's lights
  36250. * @param toRemove defines the light to remove
  36251. * @returns the index where the light was in the light list
  36252. */
  36253. removeLight(toRemove: Light): number;
  36254. /**
  36255. * Remove a camera for the list of scene's cameras
  36256. * @param toRemove defines the camera to remove
  36257. * @returns the index where the camera was in the camera list
  36258. */
  36259. removeCamera(toRemove: Camera): number;
  36260. /**
  36261. * Remove a particle system for the list of scene's particle systems
  36262. * @param toRemove defines the particle system to remove
  36263. * @returns the index where the particle system was in the particle system list
  36264. */
  36265. removeParticleSystem(toRemove: IParticleSystem): number;
  36266. /**
  36267. * Remove a animation for the list of scene's animations
  36268. * @param toRemove defines the animation to remove
  36269. * @returns the index where the animation was in the animation list
  36270. */
  36271. removeAnimation(toRemove: Animation): number;
  36272. /**
  36273. * Will stop the animation of the given target
  36274. * @param target - the target
  36275. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36276. * @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)
  36277. */
  36278. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36279. /**
  36280. * Removes the given animation group from this scene.
  36281. * @param toRemove The animation group to remove
  36282. * @returns The index of the removed animation group
  36283. */
  36284. removeAnimationGroup(toRemove: AnimationGroup): number;
  36285. /**
  36286. * Removes the given multi-material from this scene.
  36287. * @param toRemove The multi-material to remove
  36288. * @returns The index of the removed multi-material
  36289. */
  36290. removeMultiMaterial(toRemove: MultiMaterial): number;
  36291. /**
  36292. * Removes the given material from this scene.
  36293. * @param toRemove The material to remove
  36294. * @returns The index of the removed material
  36295. */
  36296. removeMaterial(toRemove: Material): number;
  36297. /**
  36298. * Removes the given action manager from this scene.
  36299. * @param toRemove The action manager to remove
  36300. * @returns The index of the removed action manager
  36301. */
  36302. removeActionManager(toRemove: AbstractActionManager): number;
  36303. /**
  36304. * Removes the given texture from this scene.
  36305. * @param toRemove The texture to remove
  36306. * @returns The index of the removed texture
  36307. */
  36308. removeTexture(toRemove: BaseTexture): number;
  36309. /**
  36310. * Adds the given light to this scene
  36311. * @param newLight The light to add
  36312. */
  36313. addLight(newLight: Light): void;
  36314. /**
  36315. * Sorts the list list based on light priorities
  36316. */
  36317. sortLightsByPriority(): void;
  36318. /**
  36319. * Adds the given camera to this scene
  36320. * @param newCamera The camera to add
  36321. */
  36322. addCamera(newCamera: Camera): void;
  36323. /**
  36324. * Adds the given skeleton to this scene
  36325. * @param newSkeleton The skeleton to add
  36326. */
  36327. addSkeleton(newSkeleton: Skeleton): void;
  36328. /**
  36329. * Adds the given particle system to this scene
  36330. * @param newParticleSystem The particle system to add
  36331. */
  36332. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36333. /**
  36334. * Adds the given animation to this scene
  36335. * @param newAnimation The animation to add
  36336. */
  36337. addAnimation(newAnimation: Animation): void;
  36338. /**
  36339. * Adds the given animation group to this scene.
  36340. * @param newAnimationGroup The animation group to add
  36341. */
  36342. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36343. /**
  36344. * Adds the given multi-material to this scene
  36345. * @param newMultiMaterial The multi-material to add
  36346. */
  36347. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36348. /**
  36349. * Adds the given material to this scene
  36350. * @param newMaterial The material to add
  36351. */
  36352. addMaterial(newMaterial: Material): void;
  36353. /**
  36354. * Adds the given morph target to this scene
  36355. * @param newMorphTargetManager The morph target to add
  36356. */
  36357. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36358. /**
  36359. * Adds the given geometry to this scene
  36360. * @param newGeometry The geometry to add
  36361. */
  36362. addGeometry(newGeometry: Geometry): void;
  36363. /**
  36364. * Adds the given action manager to this scene
  36365. * @param newActionManager The action manager to add
  36366. */
  36367. addActionManager(newActionManager: AbstractActionManager): void;
  36368. /**
  36369. * Adds the given texture to this scene.
  36370. * @param newTexture The texture to add
  36371. */
  36372. addTexture(newTexture: BaseTexture): void;
  36373. /**
  36374. * Switch active camera
  36375. * @param newCamera defines the new active camera
  36376. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36377. */
  36378. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36379. /**
  36380. * sets the active camera of the scene using its ID
  36381. * @param id defines the camera's ID
  36382. * @return the new active camera or null if none found.
  36383. */
  36384. setActiveCameraByID(id: string): Nullable<Camera>;
  36385. /**
  36386. * sets the active camera of the scene using its name
  36387. * @param name defines the camera's name
  36388. * @returns the new active camera or null if none found.
  36389. */
  36390. setActiveCameraByName(name: string): Nullable<Camera>;
  36391. /**
  36392. * get an animation group using its name
  36393. * @param name defines the material's name
  36394. * @return the animation group or null if none found.
  36395. */
  36396. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36397. /**
  36398. * Get a material using its unique id
  36399. * @param uniqueId defines the material's unique id
  36400. * @return the material or null if none found.
  36401. */
  36402. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36403. /**
  36404. * get a material using its id
  36405. * @param id defines the material's ID
  36406. * @return the material or null if none found.
  36407. */
  36408. getMaterialByID(id: string): Nullable<Material>;
  36409. /**
  36410. * Gets a the last added material using a given id
  36411. * @param id defines the material's ID
  36412. * @return the last material with the given id or null if none found.
  36413. */
  36414. getLastMaterialByID(id: string): Nullable<Material>;
  36415. /**
  36416. * Gets a material using its name
  36417. * @param name defines the material's name
  36418. * @return the material or null if none found.
  36419. */
  36420. getMaterialByName(name: string): Nullable<Material>;
  36421. /**
  36422. * Get a texture using its unique id
  36423. * @param uniqueId defines the texture's unique id
  36424. * @return the texture or null if none found.
  36425. */
  36426. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36427. /**
  36428. * Gets a camera using its id
  36429. * @param id defines the id to look for
  36430. * @returns the camera or null if not found
  36431. */
  36432. getCameraByID(id: string): Nullable<Camera>;
  36433. /**
  36434. * Gets a camera using its unique id
  36435. * @param uniqueId defines the unique id to look for
  36436. * @returns the camera or null if not found
  36437. */
  36438. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36439. /**
  36440. * Gets a camera using its name
  36441. * @param name defines the camera's name
  36442. * @return the camera or null if none found.
  36443. */
  36444. getCameraByName(name: string): Nullable<Camera>;
  36445. /**
  36446. * Gets a bone using its id
  36447. * @param id defines the bone's id
  36448. * @return the bone or null if not found
  36449. */
  36450. getBoneByID(id: string): Nullable<Bone>;
  36451. /**
  36452. * Gets a bone using its id
  36453. * @param name defines the bone's name
  36454. * @return the bone or null if not found
  36455. */
  36456. getBoneByName(name: string): Nullable<Bone>;
  36457. /**
  36458. * Gets a light node using its name
  36459. * @param name defines the the light's name
  36460. * @return the light or null if none found.
  36461. */
  36462. getLightByName(name: string): Nullable<Light>;
  36463. /**
  36464. * Gets a light node using its id
  36465. * @param id defines the light's id
  36466. * @return the light or null if none found.
  36467. */
  36468. getLightByID(id: string): Nullable<Light>;
  36469. /**
  36470. * Gets a light node using its scene-generated unique ID
  36471. * @param uniqueId defines the light's unique id
  36472. * @return the light or null if none found.
  36473. */
  36474. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36475. /**
  36476. * Gets a particle system by id
  36477. * @param id defines the particle system id
  36478. * @return the corresponding system or null if none found
  36479. */
  36480. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36481. /**
  36482. * Gets a geometry using its ID
  36483. * @param id defines the geometry's id
  36484. * @return the geometry or null if none found.
  36485. */
  36486. getGeometryByID(id: string): Nullable<Geometry>;
  36487. private _getGeometryByUniqueID;
  36488. /**
  36489. * Add a new geometry to this scene
  36490. * @param geometry defines the geometry to be added to the scene.
  36491. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36492. * @return a boolean defining if the geometry was added or not
  36493. */
  36494. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36495. /**
  36496. * Removes an existing geometry
  36497. * @param geometry defines the geometry to be removed from the scene
  36498. * @return a boolean defining if the geometry was removed or not
  36499. */
  36500. removeGeometry(geometry: Geometry): boolean;
  36501. /**
  36502. * Gets the list of geometries attached to the scene
  36503. * @returns an array of Geometry
  36504. */
  36505. getGeometries(): Geometry[];
  36506. /**
  36507. * Gets the first added mesh found of a given ID
  36508. * @param id defines the id to search for
  36509. * @return the mesh found or null if not found at all
  36510. */
  36511. getMeshByID(id: string): Nullable<AbstractMesh>;
  36512. /**
  36513. * Gets a list of meshes using their id
  36514. * @param id defines the id to search for
  36515. * @returns a list of meshes
  36516. */
  36517. getMeshesByID(id: string): Array<AbstractMesh>;
  36518. /**
  36519. * Gets the first added transform node found of a given ID
  36520. * @param id defines the id to search for
  36521. * @return the found transform node or null if not found at all.
  36522. */
  36523. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36524. /**
  36525. * Gets a transform node with its auto-generated unique id
  36526. * @param uniqueId efines the unique id to search for
  36527. * @return the found transform node or null if not found at all.
  36528. */
  36529. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36530. /**
  36531. * Gets a list of transform nodes using their id
  36532. * @param id defines the id to search for
  36533. * @returns a list of transform nodes
  36534. */
  36535. getTransformNodesByID(id: string): Array<TransformNode>;
  36536. /**
  36537. * Gets a mesh with its auto-generated unique id
  36538. * @param uniqueId defines the unique id to search for
  36539. * @return the found mesh or null if not found at all.
  36540. */
  36541. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36542. /**
  36543. * Gets a the last added mesh using a given id
  36544. * @param id defines the id to search for
  36545. * @return the found mesh or null if not found at all.
  36546. */
  36547. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36548. /**
  36549. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36550. * @param id defines the id to search for
  36551. * @return the found node or null if not found at all
  36552. */
  36553. getLastEntryByID(id: string): Nullable<Node>;
  36554. /**
  36555. * Gets a node (Mesh, Camera, Light) using a given id
  36556. * @param id defines the id to search for
  36557. * @return the found node or null if not found at all
  36558. */
  36559. getNodeByID(id: string): Nullable<Node>;
  36560. /**
  36561. * Gets a node (Mesh, Camera, Light) using a given name
  36562. * @param name defines the name to search for
  36563. * @return the found node or null if not found at all.
  36564. */
  36565. getNodeByName(name: string): Nullable<Node>;
  36566. /**
  36567. * Gets a mesh using a given name
  36568. * @param name defines the name to search for
  36569. * @return the found mesh or null if not found at all.
  36570. */
  36571. getMeshByName(name: string): Nullable<AbstractMesh>;
  36572. /**
  36573. * Gets a transform node using a given name
  36574. * @param name defines the name to search for
  36575. * @return the found transform node or null if not found at all.
  36576. */
  36577. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36578. /**
  36579. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36580. * @param id defines the id to search for
  36581. * @return the found skeleton or null if not found at all.
  36582. */
  36583. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36584. /**
  36585. * Gets a skeleton using a given auto generated unique id
  36586. * @param uniqueId defines the unique id to search for
  36587. * @return the found skeleton or null if not found at all.
  36588. */
  36589. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36590. /**
  36591. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36592. * @param id defines the id to search for
  36593. * @return the found skeleton or null if not found at all.
  36594. */
  36595. getSkeletonById(id: string): Nullable<Skeleton>;
  36596. /**
  36597. * Gets a skeleton using a given name
  36598. * @param name defines the name to search for
  36599. * @return the found skeleton or null if not found at all.
  36600. */
  36601. getSkeletonByName(name: string): Nullable<Skeleton>;
  36602. /**
  36603. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36604. * @param id defines the id to search for
  36605. * @return the found morph target manager or null if not found at all.
  36606. */
  36607. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36608. /**
  36609. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36610. * @param id defines the id to search for
  36611. * @return the found morph target or null if not found at all.
  36612. */
  36613. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36614. /**
  36615. * Gets a boolean indicating if the given mesh is active
  36616. * @param mesh defines the mesh to look for
  36617. * @returns true if the mesh is in the active list
  36618. */
  36619. isActiveMesh(mesh: AbstractMesh): boolean;
  36620. /**
  36621. * Return a unique id as a string which can serve as an identifier for the scene
  36622. */
  36623. get uid(): string;
  36624. /**
  36625. * Add an externaly attached data from its key.
  36626. * This method call will fail and return false, if such key already exists.
  36627. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36628. * @param key the unique key that identifies the data
  36629. * @param data the data object to associate to the key for this Engine instance
  36630. * @return true if no such key were already present and the data was added successfully, false otherwise
  36631. */
  36632. addExternalData<T>(key: string, data: T): boolean;
  36633. /**
  36634. * Get an externaly attached data from its key
  36635. * @param key the unique key that identifies the data
  36636. * @return the associated data, if present (can be null), or undefined if not present
  36637. */
  36638. getExternalData<T>(key: string): Nullable<T>;
  36639. /**
  36640. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36641. * @param key the unique key that identifies the data
  36642. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36643. * @return the associated data, can be null if the factory returned null.
  36644. */
  36645. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36646. /**
  36647. * Remove an externaly attached data from the Engine instance
  36648. * @param key the unique key that identifies the data
  36649. * @return true if the data was successfully removed, false if it doesn't exist
  36650. */
  36651. removeExternalData(key: string): boolean;
  36652. private _evaluateSubMesh;
  36653. /**
  36654. * Clear the processed materials smart array preventing retention point in material dispose.
  36655. */
  36656. freeProcessedMaterials(): void;
  36657. private _preventFreeActiveMeshesAndRenderingGroups;
  36658. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36659. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36660. * when disposing several meshes in a row or a hierarchy of meshes.
  36661. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36662. */
  36663. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36664. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36665. /**
  36666. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36667. */
  36668. freeActiveMeshes(): void;
  36669. /**
  36670. * Clear the info related to rendering groups preventing retention points during dispose.
  36671. */
  36672. freeRenderingGroups(): void;
  36673. /** @hidden */
  36674. _isInIntermediateRendering(): boolean;
  36675. /**
  36676. * Lambda returning the list of potentially active meshes.
  36677. */
  36678. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36679. /**
  36680. * Lambda returning the list of potentially active sub meshes.
  36681. */
  36682. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36683. /**
  36684. * Lambda returning the list of potentially intersecting sub meshes.
  36685. */
  36686. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36687. /**
  36688. * Lambda returning the list of potentially colliding sub meshes.
  36689. */
  36690. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36691. private _activeMeshesFrozen;
  36692. private _skipEvaluateActiveMeshesCompletely;
  36693. /**
  36694. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36695. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36696. * @returns the current scene
  36697. */
  36698. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36699. /**
  36700. * Use this function to restart evaluating active meshes on every frame
  36701. * @returns the current scene
  36702. */
  36703. unfreezeActiveMeshes(): Scene;
  36704. private _evaluateActiveMeshes;
  36705. private _activeMesh;
  36706. /**
  36707. * Update the transform matrix to update from the current active camera
  36708. * @param force defines a boolean used to force the update even if cache is up to date
  36709. */
  36710. updateTransformMatrix(force?: boolean): void;
  36711. private _bindFrameBuffer;
  36712. /** @hidden */
  36713. _allowPostProcessClearColor: boolean;
  36714. /** @hidden */
  36715. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36716. private _processSubCameras;
  36717. private _checkIntersections;
  36718. /** @hidden */
  36719. _advancePhysicsEngineStep(step: number): void;
  36720. /**
  36721. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36722. */
  36723. getDeterministicFrameTime: () => number;
  36724. /** @hidden */
  36725. _animate(): void;
  36726. /** Execute all animations (for a frame) */
  36727. animate(): void;
  36728. /**
  36729. * Render the scene
  36730. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36731. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36732. */
  36733. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36734. /**
  36735. * Freeze all materials
  36736. * A frozen material will not be updatable but should be faster to render
  36737. */
  36738. freezeMaterials(): void;
  36739. /**
  36740. * Unfreeze all materials
  36741. * A frozen material will not be updatable but should be faster to render
  36742. */
  36743. unfreezeMaterials(): void;
  36744. /**
  36745. * Releases all held ressources
  36746. */
  36747. dispose(): void;
  36748. /**
  36749. * Gets if the scene is already disposed
  36750. */
  36751. get isDisposed(): boolean;
  36752. /**
  36753. * Call this function to reduce memory footprint of the scene.
  36754. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36755. */
  36756. clearCachedVertexData(): void;
  36757. /**
  36758. * This function will remove the local cached buffer data from texture.
  36759. * It will save memory but will prevent the texture from being rebuilt
  36760. */
  36761. cleanCachedTextureBuffer(): void;
  36762. /**
  36763. * Get the world extend vectors with an optional filter
  36764. *
  36765. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36766. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36767. */
  36768. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36769. min: Vector3;
  36770. max: Vector3;
  36771. };
  36772. /**
  36773. * Creates a ray that can be used to pick in the scene
  36774. * @param x defines the x coordinate of the origin (on-screen)
  36775. * @param y defines the y coordinate of the origin (on-screen)
  36776. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36777. * @param camera defines the camera to use for the picking
  36778. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36779. * @returns a Ray
  36780. */
  36781. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36782. /**
  36783. * Creates a ray that can be used to pick in the scene
  36784. * @param x defines the x coordinate of the origin (on-screen)
  36785. * @param y defines the y coordinate of the origin (on-screen)
  36786. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36787. * @param result defines the ray where to store the picking ray
  36788. * @param camera defines the camera to use for the picking
  36789. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36790. * @returns the current scene
  36791. */
  36792. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36793. /**
  36794. * Creates a ray that can be used to pick in the scene
  36795. * @param x defines the x coordinate of the origin (on-screen)
  36796. * @param y defines the y coordinate of the origin (on-screen)
  36797. * @param camera defines the camera to use for the picking
  36798. * @returns a Ray
  36799. */
  36800. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36801. /**
  36802. * Creates a ray that can be used to pick in the scene
  36803. * @param x defines the x coordinate of the origin (on-screen)
  36804. * @param y defines the y coordinate of the origin (on-screen)
  36805. * @param result defines the ray where to store the picking ray
  36806. * @param camera defines the camera to use for the picking
  36807. * @returns the current scene
  36808. */
  36809. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36810. /** Launch a ray to try to pick a mesh in the scene
  36811. * @param x position on screen
  36812. * @param y position on screen
  36813. * @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
  36814. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36815. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36816. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36817. * @returns a PickingInfo
  36818. */
  36819. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36820. /** Use the given ray to pick a mesh in the scene
  36821. * @param ray The ray to use to pick meshes
  36822. * @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
  36823. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36824. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36825. * @returns a PickingInfo
  36826. */
  36827. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36828. /**
  36829. * Launch a ray to try to pick a mesh in the scene
  36830. * @param x X position on screen
  36831. * @param y Y position on screen
  36832. * @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
  36833. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36834. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36835. * @returns an array of PickingInfo
  36836. */
  36837. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36838. /**
  36839. * Launch a ray to try to pick a mesh in the scene
  36840. * @param ray Ray to use
  36841. * @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
  36842. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36843. * @returns an array of PickingInfo
  36844. */
  36845. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36846. /**
  36847. * Force the value of meshUnderPointer
  36848. * @param mesh defines the mesh to use
  36849. */
  36850. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36851. /**
  36852. * Gets the mesh under the pointer
  36853. * @returns a Mesh or null if no mesh is under the pointer
  36854. */
  36855. getPointerOverMesh(): Nullable<AbstractMesh>;
  36856. /** @hidden */
  36857. _rebuildGeometries(): void;
  36858. /** @hidden */
  36859. _rebuildTextures(): void;
  36860. private _getByTags;
  36861. /**
  36862. * Get a list of meshes by tags
  36863. * @param tagsQuery defines the tags query to use
  36864. * @param forEach defines a predicate used to filter results
  36865. * @returns an array of Mesh
  36866. */
  36867. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36868. /**
  36869. * Get a list of cameras by tags
  36870. * @param tagsQuery defines the tags query to use
  36871. * @param forEach defines a predicate used to filter results
  36872. * @returns an array of Camera
  36873. */
  36874. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36875. /**
  36876. * Get a list of lights by tags
  36877. * @param tagsQuery defines the tags query to use
  36878. * @param forEach defines a predicate used to filter results
  36879. * @returns an array of Light
  36880. */
  36881. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36882. /**
  36883. * Get a list of materials by tags
  36884. * @param tagsQuery defines the tags query to use
  36885. * @param forEach defines a predicate used to filter results
  36886. * @returns an array of Material
  36887. */
  36888. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36889. /**
  36890. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36891. * This allowed control for front to back rendering or reversly depending of the special needs.
  36892. *
  36893. * @param renderingGroupId The rendering group id corresponding to its index
  36894. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36895. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36896. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36897. */
  36898. 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;
  36899. /**
  36900. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36901. *
  36902. * @param renderingGroupId The rendering group id corresponding to its index
  36903. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36904. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36905. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36906. */
  36907. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36908. /**
  36909. * Gets the current auto clear configuration for one rendering group of the rendering
  36910. * manager.
  36911. * @param index the rendering group index to get the information for
  36912. * @returns The auto clear setup for the requested rendering group
  36913. */
  36914. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36915. private _blockMaterialDirtyMechanism;
  36916. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36917. get blockMaterialDirtyMechanism(): boolean;
  36918. set blockMaterialDirtyMechanism(value: boolean);
  36919. /**
  36920. * Will flag all materials as dirty to trigger new shader compilation
  36921. * @param flag defines the flag used to specify which material part must be marked as dirty
  36922. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36923. */
  36924. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36925. /** @hidden */
  36926. _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;
  36927. /** @hidden */
  36928. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36929. /** @hidden */
  36930. _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;
  36931. /** @hidden */
  36932. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36933. /** @hidden */
  36934. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36935. /** @hidden */
  36936. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36937. }
  36938. }
  36939. declare module BABYLON {
  36940. /**
  36941. * Set of assets to keep when moving a scene into an asset container.
  36942. */
  36943. export class KeepAssets extends AbstractScene {
  36944. }
  36945. /**
  36946. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36947. */
  36948. export class InstantiatedEntries {
  36949. /**
  36950. * List of new root nodes (eg. nodes with no parent)
  36951. */
  36952. rootNodes: TransformNode[];
  36953. /**
  36954. * List of new skeletons
  36955. */
  36956. skeletons: Skeleton[];
  36957. /**
  36958. * List of new animation groups
  36959. */
  36960. animationGroups: AnimationGroup[];
  36961. }
  36962. /**
  36963. * Container with a set of assets that can be added or removed from a scene.
  36964. */
  36965. export class AssetContainer extends AbstractScene {
  36966. private _wasAddedToScene;
  36967. /**
  36968. * The scene the AssetContainer belongs to.
  36969. */
  36970. scene: Scene;
  36971. /**
  36972. * Instantiates an AssetContainer.
  36973. * @param scene The scene the AssetContainer belongs to.
  36974. */
  36975. constructor(scene: Scene);
  36976. /**
  36977. * Instantiate or clone all meshes and add the new ones to the scene.
  36978. * Skeletons and animation groups will all be cloned
  36979. * @param nameFunction defines an optional function used to get new names for clones
  36980. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36981. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36982. */
  36983. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36984. /**
  36985. * Adds all the assets from the container to the scene.
  36986. */
  36987. addAllToScene(): void;
  36988. /**
  36989. * Removes all the assets in the container from the scene
  36990. */
  36991. removeAllFromScene(): void;
  36992. /**
  36993. * Disposes all the assets in the container
  36994. */
  36995. dispose(): void;
  36996. private _moveAssets;
  36997. /**
  36998. * Removes all the assets contained in the scene and adds them to the container.
  36999. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  37000. */
  37001. moveAllFromScene(keepAssets?: KeepAssets): void;
  37002. /**
  37003. * 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.
  37004. * @returns the root mesh
  37005. */
  37006. createRootMesh(): Mesh;
  37007. /**
  37008. * Merge animations from this asset container into a scene
  37009. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  37010. * @param animatables set of animatables to retarget to a node from the scene
  37011. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  37012. */
  37013. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37014. }
  37015. }
  37016. declare module BABYLON {
  37017. /**
  37018. * Defines how the parser contract is defined.
  37019. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37020. */
  37021. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37022. /**
  37023. * Defines how the individual parser contract is defined.
  37024. * These parser can parse an individual asset
  37025. */
  37026. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37027. /**
  37028. * Base class of the scene acting as a container for the different elements composing a scene.
  37029. * This class is dynamically extended by the different components of the scene increasing
  37030. * flexibility and reducing coupling
  37031. */
  37032. export abstract class AbstractScene {
  37033. /**
  37034. * Stores the list of available parsers in the application.
  37035. */
  37036. private static _BabylonFileParsers;
  37037. /**
  37038. * Stores the list of available individual parsers in the application.
  37039. */
  37040. private static _IndividualBabylonFileParsers;
  37041. /**
  37042. * Adds a parser in the list of available ones
  37043. * @param name Defines the name of the parser
  37044. * @param parser Defines the parser to add
  37045. */
  37046. static AddParser(name: string, parser: BabylonFileParser): void;
  37047. /**
  37048. * Gets a general parser from the list of avaialble ones
  37049. * @param name Defines the name of the parser
  37050. * @returns the requested parser or null
  37051. */
  37052. static GetParser(name: string): Nullable<BabylonFileParser>;
  37053. /**
  37054. * Adds n individual parser in the list of available ones
  37055. * @param name Defines the name of the parser
  37056. * @param parser Defines the parser to add
  37057. */
  37058. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37059. /**
  37060. * Gets an individual parser from the list of avaialble ones
  37061. * @param name Defines the name of the parser
  37062. * @returns the requested parser or null
  37063. */
  37064. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37065. /**
  37066. * Parser json data and populate both a scene and its associated container object
  37067. * @param jsonData Defines the data to parse
  37068. * @param scene Defines the scene to parse the data for
  37069. * @param container Defines the container attached to the parsing sequence
  37070. * @param rootUrl Defines the root url of the data
  37071. */
  37072. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37073. /**
  37074. * Gets the list of root nodes (ie. nodes with no parent)
  37075. */
  37076. rootNodes: Node[];
  37077. /** All of the cameras added to this scene
  37078. * @see http://doc.babylonjs.com/babylon101/cameras
  37079. */
  37080. cameras: Camera[];
  37081. /**
  37082. * All of the lights added to this scene
  37083. * @see http://doc.babylonjs.com/babylon101/lights
  37084. */
  37085. lights: Light[];
  37086. /**
  37087. * All of the (abstract) meshes added to this scene
  37088. */
  37089. meshes: AbstractMesh[];
  37090. /**
  37091. * The list of skeletons added to the scene
  37092. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37093. */
  37094. skeletons: Skeleton[];
  37095. /**
  37096. * All of the particle systems added to this scene
  37097. * @see http://doc.babylonjs.com/babylon101/particles
  37098. */
  37099. particleSystems: IParticleSystem[];
  37100. /**
  37101. * Gets a list of Animations associated with the scene
  37102. */
  37103. animations: Animation[];
  37104. /**
  37105. * All of the animation groups added to this scene
  37106. * @see http://doc.babylonjs.com/how_to/group
  37107. */
  37108. animationGroups: AnimationGroup[];
  37109. /**
  37110. * All of the multi-materials added to this scene
  37111. * @see http://doc.babylonjs.com/how_to/multi_materials
  37112. */
  37113. multiMaterials: MultiMaterial[];
  37114. /**
  37115. * All of the materials added to this scene
  37116. * In the context of a Scene, it is not supposed to be modified manually.
  37117. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37118. * Note also that the order of the Material within the array is not significant and might change.
  37119. * @see http://doc.babylonjs.com/babylon101/materials
  37120. */
  37121. materials: Material[];
  37122. /**
  37123. * The list of morph target managers added to the scene
  37124. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37125. */
  37126. morphTargetManagers: MorphTargetManager[];
  37127. /**
  37128. * The list of geometries used in the scene.
  37129. */
  37130. geometries: Geometry[];
  37131. /**
  37132. * All of the tranform nodes added to this scene
  37133. * In the context of a Scene, it is not supposed to be modified manually.
  37134. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37135. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37136. * @see http://doc.babylonjs.com/how_to/transformnode
  37137. */
  37138. transformNodes: TransformNode[];
  37139. /**
  37140. * ActionManagers available on the scene.
  37141. */
  37142. actionManagers: AbstractActionManager[];
  37143. /**
  37144. * Textures to keep.
  37145. */
  37146. textures: BaseTexture[];
  37147. /**
  37148. * Environment texture for the scene
  37149. */
  37150. environmentTexture: Nullable<BaseTexture>;
  37151. /**
  37152. * @returns all meshes, lights, cameras, transformNodes and bones
  37153. */
  37154. getNodes(): Array<Node>;
  37155. }
  37156. }
  37157. declare module BABYLON {
  37158. /**
  37159. * Interface used to define options for Sound class
  37160. */
  37161. export interface ISoundOptions {
  37162. /**
  37163. * Does the sound autoplay once loaded.
  37164. */
  37165. autoplay?: boolean;
  37166. /**
  37167. * Does the sound loop after it finishes playing once.
  37168. */
  37169. loop?: boolean;
  37170. /**
  37171. * Sound's volume
  37172. */
  37173. volume?: number;
  37174. /**
  37175. * Is it a spatial sound?
  37176. */
  37177. spatialSound?: boolean;
  37178. /**
  37179. * Maximum distance to hear that sound
  37180. */
  37181. maxDistance?: number;
  37182. /**
  37183. * Uses user defined attenuation function
  37184. */
  37185. useCustomAttenuation?: boolean;
  37186. /**
  37187. * Define the roll off factor of spatial sounds.
  37188. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37189. */
  37190. rolloffFactor?: number;
  37191. /**
  37192. * Define the reference distance the sound should be heard perfectly.
  37193. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37194. */
  37195. refDistance?: number;
  37196. /**
  37197. * Define the distance attenuation model the sound will follow.
  37198. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37199. */
  37200. distanceModel?: string;
  37201. /**
  37202. * Defines the playback speed (1 by default)
  37203. */
  37204. playbackRate?: number;
  37205. /**
  37206. * Defines if the sound is from a streaming source
  37207. */
  37208. streaming?: boolean;
  37209. /**
  37210. * Defines an optional length (in seconds) inside the sound file
  37211. */
  37212. length?: number;
  37213. /**
  37214. * Defines an optional offset (in seconds) inside the sound file
  37215. */
  37216. offset?: number;
  37217. /**
  37218. * If true, URLs will not be required to state the audio file codec to use.
  37219. */
  37220. skipCodecCheck?: boolean;
  37221. }
  37222. /**
  37223. * Defines a sound that can be played in the application.
  37224. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37226. */
  37227. export class Sound {
  37228. /**
  37229. * The name of the sound in the scene.
  37230. */
  37231. name: string;
  37232. /**
  37233. * Does the sound autoplay once loaded.
  37234. */
  37235. autoplay: boolean;
  37236. /**
  37237. * Does the sound loop after it finishes playing once.
  37238. */
  37239. loop: boolean;
  37240. /**
  37241. * Does the sound use a custom attenuation curve to simulate the falloff
  37242. * happening when the source gets further away from the camera.
  37243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37244. */
  37245. useCustomAttenuation: boolean;
  37246. /**
  37247. * The sound track id this sound belongs to.
  37248. */
  37249. soundTrackId: number;
  37250. /**
  37251. * Is this sound currently played.
  37252. */
  37253. isPlaying: boolean;
  37254. /**
  37255. * Is this sound currently paused.
  37256. */
  37257. isPaused: boolean;
  37258. /**
  37259. * Does this sound enables spatial sound.
  37260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37261. */
  37262. spatialSound: boolean;
  37263. /**
  37264. * Define the reference distance the sound should be heard perfectly.
  37265. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37266. */
  37267. refDistance: number;
  37268. /**
  37269. * Define the roll off factor of spatial sounds.
  37270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37271. */
  37272. rolloffFactor: number;
  37273. /**
  37274. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37276. */
  37277. maxDistance: number;
  37278. /**
  37279. * Define the distance attenuation model the sound will follow.
  37280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37281. */
  37282. distanceModel: string;
  37283. /**
  37284. * @hidden
  37285. * Back Compat
  37286. **/
  37287. onended: () => any;
  37288. /**
  37289. * Observable event when the current playing sound finishes.
  37290. */
  37291. onEndedObservable: Observable<Sound>;
  37292. private _panningModel;
  37293. private _playbackRate;
  37294. private _streaming;
  37295. private _startTime;
  37296. private _startOffset;
  37297. private _position;
  37298. /** @hidden */
  37299. _positionInEmitterSpace: boolean;
  37300. private _localDirection;
  37301. private _volume;
  37302. private _isReadyToPlay;
  37303. private _isDirectional;
  37304. private _readyToPlayCallback;
  37305. private _audioBuffer;
  37306. private _soundSource;
  37307. private _streamingSource;
  37308. private _soundPanner;
  37309. private _soundGain;
  37310. private _inputAudioNode;
  37311. private _outputAudioNode;
  37312. private _coneInnerAngle;
  37313. private _coneOuterAngle;
  37314. private _coneOuterGain;
  37315. private _scene;
  37316. private _connectedTransformNode;
  37317. private _customAttenuationFunction;
  37318. private _registerFunc;
  37319. private _isOutputConnected;
  37320. private _htmlAudioElement;
  37321. private _urlType;
  37322. private _length?;
  37323. private _offset?;
  37324. /** @hidden */
  37325. static _SceneComponentInitialization: (scene: Scene) => void;
  37326. /**
  37327. * Create a sound and attach it to a scene
  37328. * @param name Name of your sound
  37329. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37330. * @param scene defines the scene the sound belongs to
  37331. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37332. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37333. */
  37334. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37335. /**
  37336. * Release the sound and its associated resources
  37337. */
  37338. dispose(): void;
  37339. /**
  37340. * Gets if the sounds is ready to be played or not.
  37341. * @returns true if ready, otherwise false
  37342. */
  37343. isReady(): boolean;
  37344. private _soundLoaded;
  37345. /**
  37346. * Sets the data of the sound from an audiobuffer
  37347. * @param audioBuffer The audioBuffer containing the data
  37348. */
  37349. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37350. /**
  37351. * Updates the current sounds options such as maxdistance, loop...
  37352. * @param options A JSON object containing values named as the object properties
  37353. */
  37354. updateOptions(options: ISoundOptions): void;
  37355. private _createSpatialParameters;
  37356. private _updateSpatialParameters;
  37357. /**
  37358. * Switch the panning model to HRTF:
  37359. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37360. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37361. */
  37362. switchPanningModelToHRTF(): void;
  37363. /**
  37364. * Switch the panning model to Equal Power:
  37365. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37367. */
  37368. switchPanningModelToEqualPower(): void;
  37369. private _switchPanningModel;
  37370. /**
  37371. * Connect this sound to a sound track audio node like gain...
  37372. * @param soundTrackAudioNode the sound track audio node to connect to
  37373. */
  37374. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37375. /**
  37376. * Transform this sound into a directional source
  37377. * @param coneInnerAngle Size of the inner cone in degree
  37378. * @param coneOuterAngle Size of the outer cone in degree
  37379. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37380. */
  37381. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37382. /**
  37383. * Gets or sets the inner angle for the directional cone.
  37384. */
  37385. get directionalConeInnerAngle(): number;
  37386. /**
  37387. * Gets or sets the inner angle for the directional cone.
  37388. */
  37389. set directionalConeInnerAngle(value: number);
  37390. /**
  37391. * Gets or sets the outer angle for the directional cone.
  37392. */
  37393. get directionalConeOuterAngle(): number;
  37394. /**
  37395. * Gets or sets the outer angle for the directional cone.
  37396. */
  37397. set directionalConeOuterAngle(value: number);
  37398. /**
  37399. * Sets the position of the emitter if spatial sound is enabled
  37400. * @param newPosition Defines the new posisiton
  37401. */
  37402. setPosition(newPosition: Vector3): void;
  37403. /**
  37404. * Sets the local direction of the emitter if spatial sound is enabled
  37405. * @param newLocalDirection Defines the new local direction
  37406. */
  37407. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37408. private _updateDirection;
  37409. /** @hidden */
  37410. updateDistanceFromListener(): void;
  37411. /**
  37412. * Sets a new custom attenuation function for the sound.
  37413. * @param callback Defines the function used for the attenuation
  37414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37415. */
  37416. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37417. /**
  37418. * Play the sound
  37419. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37420. * @param offset (optional) Start the sound at a specific time in seconds
  37421. * @param length (optional) Sound duration (in seconds)
  37422. */
  37423. play(time?: number, offset?: number, length?: number): void;
  37424. private _onended;
  37425. /**
  37426. * Stop the sound
  37427. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37428. */
  37429. stop(time?: number): void;
  37430. /**
  37431. * Put the sound in pause
  37432. */
  37433. pause(): void;
  37434. /**
  37435. * Sets a dedicated volume for this sounds
  37436. * @param newVolume Define the new volume of the sound
  37437. * @param time Define time for gradual change to new volume
  37438. */
  37439. setVolume(newVolume: number, time?: number): void;
  37440. /**
  37441. * Set the sound play back rate
  37442. * @param newPlaybackRate Define the playback rate the sound should be played at
  37443. */
  37444. setPlaybackRate(newPlaybackRate: number): void;
  37445. /**
  37446. * Gets the volume of the sound.
  37447. * @returns the volume of the sound
  37448. */
  37449. getVolume(): number;
  37450. /**
  37451. * Attach the sound to a dedicated mesh
  37452. * @param transformNode The transform node to connect the sound with
  37453. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37454. */
  37455. attachToMesh(transformNode: TransformNode): void;
  37456. /**
  37457. * Detach the sound from the previously attached mesh
  37458. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37459. */
  37460. detachFromMesh(): void;
  37461. private _onRegisterAfterWorldMatrixUpdate;
  37462. /**
  37463. * Clone the current sound in the scene.
  37464. * @returns the new sound clone
  37465. */
  37466. clone(): Nullable<Sound>;
  37467. /**
  37468. * Gets the current underlying audio buffer containing the data
  37469. * @returns the audio buffer
  37470. */
  37471. getAudioBuffer(): Nullable<AudioBuffer>;
  37472. /**
  37473. * Serializes the Sound in a JSON representation
  37474. * @returns the JSON representation of the sound
  37475. */
  37476. serialize(): any;
  37477. /**
  37478. * Parse a JSON representation of a sound to innstantiate in a given scene
  37479. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37480. * @param scene Define the scene the new parsed sound should be created in
  37481. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37482. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37483. * @returns the newly parsed sound
  37484. */
  37485. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37486. }
  37487. }
  37488. declare module BABYLON {
  37489. /**
  37490. * This defines an action helpful to play a defined sound on a triggered action.
  37491. */
  37492. export class PlaySoundAction extends Action {
  37493. private _sound;
  37494. /**
  37495. * Instantiate the action
  37496. * @param triggerOptions defines the trigger options
  37497. * @param sound defines the sound to play
  37498. * @param condition defines the trigger related conditions
  37499. */
  37500. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37501. /** @hidden */
  37502. _prepare(): void;
  37503. /**
  37504. * Execute the action and play the sound.
  37505. */
  37506. execute(): void;
  37507. /**
  37508. * Serializes the actions and its related information.
  37509. * @param parent defines the object to serialize in
  37510. * @returns the serialized object
  37511. */
  37512. serialize(parent: any): any;
  37513. }
  37514. /**
  37515. * This defines an action helpful to stop a defined sound on a triggered action.
  37516. */
  37517. export class StopSoundAction extends Action {
  37518. private _sound;
  37519. /**
  37520. * Instantiate the action
  37521. * @param triggerOptions defines the trigger options
  37522. * @param sound defines the sound to stop
  37523. * @param condition defines the trigger related conditions
  37524. */
  37525. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37526. /** @hidden */
  37527. _prepare(): void;
  37528. /**
  37529. * Execute the action and stop the sound.
  37530. */
  37531. execute(): void;
  37532. /**
  37533. * Serializes the actions and its related information.
  37534. * @param parent defines the object to serialize in
  37535. * @returns the serialized object
  37536. */
  37537. serialize(parent: any): any;
  37538. }
  37539. }
  37540. declare module BABYLON {
  37541. /**
  37542. * This defines an action responsible to change the value of a property
  37543. * by interpolating between its current value and the newly set one once triggered.
  37544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37545. */
  37546. export class InterpolateValueAction extends Action {
  37547. /**
  37548. * Defines the path of the property where the value should be interpolated
  37549. */
  37550. propertyPath: string;
  37551. /**
  37552. * Defines the target value at the end of the interpolation.
  37553. */
  37554. value: any;
  37555. /**
  37556. * Defines the time it will take for the property to interpolate to the value.
  37557. */
  37558. duration: number;
  37559. /**
  37560. * Defines if the other scene animations should be stopped when the action has been triggered
  37561. */
  37562. stopOtherAnimations?: boolean;
  37563. /**
  37564. * Defines a callback raised once the interpolation animation has been done.
  37565. */
  37566. onInterpolationDone?: () => void;
  37567. /**
  37568. * Observable triggered once the interpolation animation has been done.
  37569. */
  37570. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37571. private _target;
  37572. private _effectiveTarget;
  37573. private _property;
  37574. /**
  37575. * Instantiate the action
  37576. * @param triggerOptions defines the trigger options
  37577. * @param target defines the object containing the value to interpolate
  37578. * @param propertyPath defines the path to the property in the target object
  37579. * @param value defines the target value at the end of the interpolation
  37580. * @param duration deines the time it will take for the property to interpolate to the value.
  37581. * @param condition defines the trigger related conditions
  37582. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37583. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37584. */
  37585. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37586. /** @hidden */
  37587. _prepare(): void;
  37588. /**
  37589. * Execute the action starts the value interpolation.
  37590. */
  37591. execute(): void;
  37592. /**
  37593. * Serializes the actions and its related information.
  37594. * @param parent defines the object to serialize in
  37595. * @returns the serialized object
  37596. */
  37597. serialize(parent: any): any;
  37598. }
  37599. }
  37600. declare module BABYLON {
  37601. /**
  37602. * Options allowed during the creation of a sound track.
  37603. */
  37604. export interface ISoundTrackOptions {
  37605. /**
  37606. * The volume the sound track should take during creation
  37607. */
  37608. volume?: number;
  37609. /**
  37610. * Define if the sound track is the main sound track of the scene
  37611. */
  37612. mainTrack?: boolean;
  37613. }
  37614. /**
  37615. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37616. * It will be also used in a future release to apply effects on a specific track.
  37617. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37618. */
  37619. export class SoundTrack {
  37620. /**
  37621. * The unique identifier of the sound track in the scene.
  37622. */
  37623. id: number;
  37624. /**
  37625. * The list of sounds included in the sound track.
  37626. */
  37627. soundCollection: Array<Sound>;
  37628. private _outputAudioNode;
  37629. private _scene;
  37630. private _connectedAnalyser;
  37631. private _options;
  37632. private _isInitialized;
  37633. /**
  37634. * Creates a new sound track.
  37635. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37636. * @param scene Define the scene the sound track belongs to
  37637. * @param options
  37638. */
  37639. constructor(scene: Scene, options?: ISoundTrackOptions);
  37640. private _initializeSoundTrackAudioGraph;
  37641. /**
  37642. * Release the sound track and its associated resources
  37643. */
  37644. dispose(): void;
  37645. /**
  37646. * Adds a sound to this sound track
  37647. * @param sound define the cound to add
  37648. * @ignoreNaming
  37649. */
  37650. AddSound(sound: Sound): void;
  37651. /**
  37652. * Removes a sound to this sound track
  37653. * @param sound define the cound to remove
  37654. * @ignoreNaming
  37655. */
  37656. RemoveSound(sound: Sound): void;
  37657. /**
  37658. * Set a global volume for the full sound track.
  37659. * @param newVolume Define the new volume of the sound track
  37660. */
  37661. setVolume(newVolume: number): void;
  37662. /**
  37663. * Switch the panning model to HRTF:
  37664. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37665. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37666. */
  37667. switchPanningModelToHRTF(): void;
  37668. /**
  37669. * Switch the panning model to Equal Power:
  37670. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37671. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37672. */
  37673. switchPanningModelToEqualPower(): void;
  37674. /**
  37675. * Connect the sound track to an audio analyser allowing some amazing
  37676. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37677. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37678. * @param analyser The analyser to connect to the engine
  37679. */
  37680. connectToAnalyser(analyser: Analyser): void;
  37681. }
  37682. }
  37683. declare module BABYLON {
  37684. interface AbstractScene {
  37685. /**
  37686. * The list of sounds used in the scene.
  37687. */
  37688. sounds: Nullable<Array<Sound>>;
  37689. }
  37690. interface Scene {
  37691. /**
  37692. * @hidden
  37693. * Backing field
  37694. */
  37695. _mainSoundTrack: SoundTrack;
  37696. /**
  37697. * The main sound track played by the scene.
  37698. * It cotains your primary collection of sounds.
  37699. */
  37700. mainSoundTrack: SoundTrack;
  37701. /**
  37702. * The list of sound tracks added to the scene
  37703. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37704. */
  37705. soundTracks: Nullable<Array<SoundTrack>>;
  37706. /**
  37707. * Gets a sound using a given name
  37708. * @param name defines the name to search for
  37709. * @return the found sound or null if not found at all.
  37710. */
  37711. getSoundByName(name: string): Nullable<Sound>;
  37712. /**
  37713. * Gets or sets if audio support is enabled
  37714. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37715. */
  37716. audioEnabled: boolean;
  37717. /**
  37718. * Gets or sets if audio will be output to headphones
  37719. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37720. */
  37721. headphone: boolean;
  37722. /**
  37723. * Gets or sets custom audio listener position provider
  37724. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37725. */
  37726. audioListenerPositionProvider: Nullable<() => Vector3>;
  37727. /**
  37728. * Gets or sets a refresh rate when using 3D audio positioning
  37729. */
  37730. audioPositioningRefreshRate: number;
  37731. }
  37732. /**
  37733. * Defines the sound scene component responsible to manage any sounds
  37734. * in a given scene.
  37735. */
  37736. export class AudioSceneComponent implements ISceneSerializableComponent {
  37737. /**
  37738. * The component name helpfull to identify the component in the list of scene components.
  37739. */
  37740. readonly name: string;
  37741. /**
  37742. * The scene the component belongs to.
  37743. */
  37744. scene: Scene;
  37745. private _audioEnabled;
  37746. /**
  37747. * Gets whether audio is enabled or not.
  37748. * Please use related enable/disable method to switch state.
  37749. */
  37750. get audioEnabled(): boolean;
  37751. private _headphone;
  37752. /**
  37753. * Gets whether audio is outputing to headphone or not.
  37754. * Please use the according Switch methods to change output.
  37755. */
  37756. get headphone(): boolean;
  37757. /**
  37758. * Gets or sets a refresh rate when using 3D audio positioning
  37759. */
  37760. audioPositioningRefreshRate: number;
  37761. private _audioListenerPositionProvider;
  37762. /**
  37763. * Gets the current audio listener position provider
  37764. */
  37765. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37766. /**
  37767. * Sets a custom listener position for all sounds in the scene
  37768. * By default, this is the position of the first active camera
  37769. */
  37770. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37771. /**
  37772. * Creates a new instance of the component for the given scene
  37773. * @param scene Defines the scene to register the component in
  37774. */
  37775. constructor(scene: Scene);
  37776. /**
  37777. * Registers the component in a given scene
  37778. */
  37779. register(): void;
  37780. /**
  37781. * Rebuilds the elements related to this component in case of
  37782. * context lost for instance.
  37783. */
  37784. rebuild(): void;
  37785. /**
  37786. * Serializes the component data to the specified json object
  37787. * @param serializationObject The object to serialize to
  37788. */
  37789. serialize(serializationObject: any): void;
  37790. /**
  37791. * Adds all the elements from the container to the scene
  37792. * @param container the container holding the elements
  37793. */
  37794. addFromContainer(container: AbstractScene): void;
  37795. /**
  37796. * Removes all the elements in the container from the scene
  37797. * @param container contains the elements to remove
  37798. * @param dispose if the removed element should be disposed (default: false)
  37799. */
  37800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37801. /**
  37802. * Disposes the component and the associated ressources.
  37803. */
  37804. dispose(): void;
  37805. /**
  37806. * Disables audio in the associated scene.
  37807. */
  37808. disableAudio(): void;
  37809. /**
  37810. * Enables audio in the associated scene.
  37811. */
  37812. enableAudio(): void;
  37813. /**
  37814. * Switch audio to headphone output.
  37815. */
  37816. switchAudioModeForHeadphones(): void;
  37817. /**
  37818. * Switch audio to normal speakers.
  37819. */
  37820. switchAudioModeForNormalSpeakers(): void;
  37821. private _cachedCameraDirection;
  37822. private _cachedCameraPosition;
  37823. private _lastCheck;
  37824. private _afterRender;
  37825. }
  37826. }
  37827. declare module BABYLON {
  37828. /**
  37829. * Wraps one or more Sound objects and selects one with random weight for playback.
  37830. */
  37831. export class WeightedSound {
  37832. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37833. loop: boolean;
  37834. private _coneInnerAngle;
  37835. private _coneOuterAngle;
  37836. private _volume;
  37837. /** A Sound is currently playing. */
  37838. isPlaying: boolean;
  37839. /** A Sound is currently paused. */
  37840. isPaused: boolean;
  37841. private _sounds;
  37842. private _weights;
  37843. private _currentIndex?;
  37844. /**
  37845. * Creates a new WeightedSound from the list of sounds given.
  37846. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37847. * @param sounds Array of Sounds that will be selected from.
  37848. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37849. */
  37850. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37851. /**
  37852. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37853. */
  37854. get directionalConeInnerAngle(): number;
  37855. /**
  37856. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37857. */
  37858. set directionalConeInnerAngle(value: number);
  37859. /**
  37860. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37861. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37862. */
  37863. get directionalConeOuterAngle(): number;
  37864. /**
  37865. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37866. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37867. */
  37868. set directionalConeOuterAngle(value: number);
  37869. /**
  37870. * Playback volume.
  37871. */
  37872. get volume(): number;
  37873. /**
  37874. * Playback volume.
  37875. */
  37876. set volume(value: number);
  37877. private _onended;
  37878. /**
  37879. * Suspend playback
  37880. */
  37881. pause(): void;
  37882. /**
  37883. * Stop playback
  37884. */
  37885. stop(): void;
  37886. /**
  37887. * Start playback.
  37888. * @param startOffset Position the clip head at a specific time in seconds.
  37889. */
  37890. play(startOffset?: number): void;
  37891. }
  37892. }
  37893. declare module BABYLON {
  37894. /**
  37895. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37897. */
  37898. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37899. /**
  37900. * Gets the name of the behavior.
  37901. */
  37902. get name(): string;
  37903. /**
  37904. * The easing function used by animations
  37905. */
  37906. static EasingFunction: BackEase;
  37907. /**
  37908. * The easing mode used by animations
  37909. */
  37910. static EasingMode: number;
  37911. /**
  37912. * The duration of the animation, in milliseconds
  37913. */
  37914. transitionDuration: number;
  37915. /**
  37916. * Length of the distance animated by the transition when lower radius is reached
  37917. */
  37918. lowerRadiusTransitionRange: number;
  37919. /**
  37920. * Length of the distance animated by the transition when upper radius is reached
  37921. */
  37922. upperRadiusTransitionRange: number;
  37923. private _autoTransitionRange;
  37924. /**
  37925. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37926. */
  37927. get autoTransitionRange(): boolean;
  37928. /**
  37929. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37930. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37931. */
  37932. set autoTransitionRange(value: boolean);
  37933. private _attachedCamera;
  37934. private _onAfterCheckInputsObserver;
  37935. private _onMeshTargetChangedObserver;
  37936. /**
  37937. * Initializes the behavior.
  37938. */
  37939. init(): void;
  37940. /**
  37941. * Attaches the behavior to its arc rotate camera.
  37942. * @param camera Defines the camera to attach the behavior to
  37943. */
  37944. attach(camera: ArcRotateCamera): void;
  37945. /**
  37946. * Detaches the behavior from its current arc rotate camera.
  37947. */
  37948. detach(): void;
  37949. private _radiusIsAnimating;
  37950. private _radiusBounceTransition;
  37951. private _animatables;
  37952. private _cachedWheelPrecision;
  37953. /**
  37954. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37955. * @param radiusLimit The limit to check against.
  37956. * @return Bool to indicate if at limit.
  37957. */
  37958. private _isRadiusAtLimit;
  37959. /**
  37960. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37961. * @param radiusDelta The delta by which to animate to. Can be negative.
  37962. */
  37963. private _applyBoundRadiusAnimation;
  37964. /**
  37965. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37966. */
  37967. protected _clearAnimationLocks(): void;
  37968. /**
  37969. * Stops and removes all animations that have been applied to the camera
  37970. */
  37971. stopAllAnimations(): void;
  37972. }
  37973. }
  37974. declare module BABYLON {
  37975. /**
  37976. * 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.
  37977. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37978. */
  37979. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37980. /**
  37981. * Gets the name of the behavior.
  37982. */
  37983. get name(): string;
  37984. private _mode;
  37985. private _radiusScale;
  37986. private _positionScale;
  37987. private _defaultElevation;
  37988. private _elevationReturnTime;
  37989. private _elevationReturnWaitTime;
  37990. private _zoomStopsAnimation;
  37991. private _framingTime;
  37992. /**
  37993. * The easing function used by animations
  37994. */
  37995. static EasingFunction: ExponentialEase;
  37996. /**
  37997. * The easing mode used by animations
  37998. */
  37999. static EasingMode: number;
  38000. /**
  38001. * Sets the current mode used by the behavior
  38002. */
  38003. set mode(mode: number);
  38004. /**
  38005. * Gets current mode used by the behavior.
  38006. */
  38007. get mode(): number;
  38008. /**
  38009. * Sets the scale applied to the radius (1 by default)
  38010. */
  38011. set radiusScale(radius: number);
  38012. /**
  38013. * Gets the scale applied to the radius
  38014. */
  38015. get radiusScale(): number;
  38016. /**
  38017. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38018. */
  38019. set positionScale(scale: number);
  38020. /**
  38021. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38022. */
  38023. get positionScale(): number;
  38024. /**
  38025. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38026. * behaviour is triggered, in radians.
  38027. */
  38028. set defaultElevation(elevation: number);
  38029. /**
  38030. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38031. * behaviour is triggered, in radians.
  38032. */
  38033. get defaultElevation(): number;
  38034. /**
  38035. * Sets the time (in milliseconds) taken to return to the default beta position.
  38036. * Negative value indicates camera should not return to default.
  38037. */
  38038. set elevationReturnTime(speed: number);
  38039. /**
  38040. * Gets the time (in milliseconds) taken to return to the default beta position.
  38041. * Negative value indicates camera should not return to default.
  38042. */
  38043. get elevationReturnTime(): number;
  38044. /**
  38045. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38046. */
  38047. set elevationReturnWaitTime(time: number);
  38048. /**
  38049. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38050. */
  38051. get elevationReturnWaitTime(): number;
  38052. /**
  38053. * Sets the flag that indicates if user zooming should stop animation.
  38054. */
  38055. set zoomStopsAnimation(flag: boolean);
  38056. /**
  38057. * Gets the flag that indicates if user zooming should stop animation.
  38058. */
  38059. get zoomStopsAnimation(): boolean;
  38060. /**
  38061. * Sets the transition time when framing the mesh, in milliseconds
  38062. */
  38063. set framingTime(time: number);
  38064. /**
  38065. * Gets the transition time when framing the mesh, in milliseconds
  38066. */
  38067. get framingTime(): number;
  38068. /**
  38069. * Define if the behavior should automatically change the configured
  38070. * camera limits and sensibilities.
  38071. */
  38072. autoCorrectCameraLimitsAndSensibility: boolean;
  38073. private _onPrePointerObservableObserver;
  38074. private _onAfterCheckInputsObserver;
  38075. private _onMeshTargetChangedObserver;
  38076. private _attachedCamera;
  38077. private _isPointerDown;
  38078. private _lastInteractionTime;
  38079. /**
  38080. * Initializes the behavior.
  38081. */
  38082. init(): void;
  38083. /**
  38084. * Attaches the behavior to its arc rotate camera.
  38085. * @param camera Defines the camera to attach the behavior to
  38086. */
  38087. attach(camera: ArcRotateCamera): void;
  38088. /**
  38089. * Detaches the behavior from its current arc rotate camera.
  38090. */
  38091. detach(): void;
  38092. private _animatables;
  38093. private _betaIsAnimating;
  38094. private _betaTransition;
  38095. private _radiusTransition;
  38096. private _vectorTransition;
  38097. /**
  38098. * Targets the given mesh and updates zoom level accordingly.
  38099. * @param mesh The mesh to target.
  38100. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38101. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38102. */
  38103. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38104. /**
  38105. * Targets the given mesh with its children and updates zoom level accordingly.
  38106. * @param mesh The mesh to target.
  38107. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38108. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38109. */
  38110. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38111. /**
  38112. * Targets the given meshes with their children and updates zoom level accordingly.
  38113. * @param meshes The mesh to target.
  38114. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38115. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38116. */
  38117. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38118. /**
  38119. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38120. * @param minimumWorld Determines the smaller position of the bounding box extend
  38121. * @param maximumWorld Determines the bigger position of the bounding box extend
  38122. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38123. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38124. */
  38125. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38126. /**
  38127. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38128. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38129. * frustum width.
  38130. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38131. * to fully enclose the mesh in the viewing frustum.
  38132. */
  38133. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38134. /**
  38135. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38136. * is automatically returned to its default position (expected to be above ground plane).
  38137. */
  38138. private _maintainCameraAboveGround;
  38139. /**
  38140. * Returns the frustum slope based on the canvas ratio and camera FOV
  38141. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38142. */
  38143. private _getFrustumSlope;
  38144. /**
  38145. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38146. */
  38147. private _clearAnimationLocks;
  38148. /**
  38149. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38150. */
  38151. private _applyUserInteraction;
  38152. /**
  38153. * Stops and removes all animations that have been applied to the camera
  38154. */
  38155. stopAllAnimations(): void;
  38156. /**
  38157. * Gets a value indicating if the user is moving the camera
  38158. */
  38159. get isUserIsMoving(): boolean;
  38160. /**
  38161. * The camera can move all the way towards the mesh.
  38162. */
  38163. static IgnoreBoundsSizeMode: number;
  38164. /**
  38165. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38166. */
  38167. static FitFrustumSidesMode: number;
  38168. }
  38169. }
  38170. declare module BABYLON {
  38171. /**
  38172. * Base class for Camera Pointer Inputs.
  38173. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38174. * for example usage.
  38175. */
  38176. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38177. /**
  38178. * Defines the camera the input is attached to.
  38179. */
  38180. abstract camera: Camera;
  38181. /**
  38182. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38183. */
  38184. protected _altKey: boolean;
  38185. protected _ctrlKey: boolean;
  38186. protected _metaKey: boolean;
  38187. protected _shiftKey: boolean;
  38188. /**
  38189. * Which mouse buttons were pressed at time of last mouse event.
  38190. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38191. */
  38192. protected _buttonsPressed: number;
  38193. /**
  38194. * Defines the buttons associated with the input to handle camera move.
  38195. */
  38196. buttons: number[];
  38197. /**
  38198. * Attach the input controls to a specific dom element to get the input from.
  38199. * @param element Defines the element the controls should be listened from
  38200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38201. */
  38202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38203. /**
  38204. * Detach the current controls from the specified dom element.
  38205. * @param element Defines the element to stop listening the inputs from
  38206. */
  38207. detachControl(element: Nullable<HTMLElement>): void;
  38208. /**
  38209. * Gets the class name of the current input.
  38210. * @returns the class name
  38211. */
  38212. getClassName(): string;
  38213. /**
  38214. * Get the friendly name associated with the input class.
  38215. * @returns the input friendly name
  38216. */
  38217. getSimpleName(): string;
  38218. /**
  38219. * Called on pointer POINTERDOUBLETAP event.
  38220. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38221. */
  38222. protected onDoubleTap(type: string): void;
  38223. /**
  38224. * Called on pointer POINTERMOVE event if only a single touch is active.
  38225. * Override this method to provide functionality.
  38226. */
  38227. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38228. /**
  38229. * Called on pointer POINTERMOVE event if multiple touches are active.
  38230. * Override this method to provide functionality.
  38231. */
  38232. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38233. /**
  38234. * Called on JS contextmenu event.
  38235. * Override this method to provide functionality.
  38236. */
  38237. protected onContextMenu(evt: PointerEvent): void;
  38238. /**
  38239. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38240. * press.
  38241. * Override this method to provide functionality.
  38242. */
  38243. protected onButtonDown(evt: PointerEvent): void;
  38244. /**
  38245. * Called each time a new POINTERUP event occurs. Ie, for each button
  38246. * release.
  38247. * Override this method to provide functionality.
  38248. */
  38249. protected onButtonUp(evt: PointerEvent): void;
  38250. /**
  38251. * Called when window becomes inactive.
  38252. * Override this method to provide functionality.
  38253. */
  38254. protected onLostFocus(): void;
  38255. private _pointerInput;
  38256. private _observer;
  38257. private _onLostFocus;
  38258. private pointA;
  38259. private pointB;
  38260. }
  38261. }
  38262. declare module BABYLON {
  38263. /**
  38264. * Manage the pointers inputs to control an arc rotate camera.
  38265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38266. */
  38267. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38268. /**
  38269. * Defines the camera the input is attached to.
  38270. */
  38271. camera: ArcRotateCamera;
  38272. /**
  38273. * Gets the class name of the current input.
  38274. * @returns the class name
  38275. */
  38276. getClassName(): string;
  38277. /**
  38278. * Defines the buttons associated with the input to handle camera move.
  38279. */
  38280. buttons: number[];
  38281. /**
  38282. * Defines the pointer angular sensibility along the X axis or how fast is
  38283. * the camera rotating.
  38284. */
  38285. angularSensibilityX: number;
  38286. /**
  38287. * Defines the pointer angular sensibility along the Y axis or how fast is
  38288. * the camera rotating.
  38289. */
  38290. angularSensibilityY: number;
  38291. /**
  38292. * Defines the pointer pinch precision or how fast is the camera zooming.
  38293. */
  38294. pinchPrecision: number;
  38295. /**
  38296. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38297. * from 0.
  38298. * It defines the percentage of current camera.radius to use as delta when
  38299. * pinch zoom is used.
  38300. */
  38301. pinchDeltaPercentage: number;
  38302. /**
  38303. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38304. * that any object in the plane at the camera's target point will scale
  38305. * perfectly with finger motion.
  38306. * Overrides pinchDeltaPercentage and pinchPrecision.
  38307. */
  38308. useNaturalPinchZoom: boolean;
  38309. /**
  38310. * Defines the pointer panning sensibility or how fast is the camera moving.
  38311. */
  38312. panningSensibility: number;
  38313. /**
  38314. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38315. */
  38316. multiTouchPanning: boolean;
  38317. /**
  38318. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38319. * zoom (pinch) through multitouch.
  38320. */
  38321. multiTouchPanAndZoom: boolean;
  38322. /**
  38323. * Revers pinch action direction.
  38324. */
  38325. pinchInwards: boolean;
  38326. private _isPanClick;
  38327. private _twoFingerActivityCount;
  38328. private _isPinching;
  38329. /**
  38330. * Called on pointer POINTERMOVE event if only a single touch is active.
  38331. */
  38332. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38333. /**
  38334. * Called on pointer POINTERDOUBLETAP event.
  38335. */
  38336. protected onDoubleTap(type: string): void;
  38337. /**
  38338. * Called on pointer POINTERMOVE event if multiple touches are active.
  38339. */
  38340. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38341. /**
  38342. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38343. * press.
  38344. */
  38345. protected onButtonDown(evt: PointerEvent): void;
  38346. /**
  38347. * Called each time a new POINTERUP event occurs. Ie, for each button
  38348. * release.
  38349. */
  38350. protected onButtonUp(evt: PointerEvent): void;
  38351. /**
  38352. * Called when window becomes inactive.
  38353. */
  38354. protected onLostFocus(): void;
  38355. }
  38356. }
  38357. declare module BABYLON {
  38358. /**
  38359. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38361. */
  38362. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38363. /**
  38364. * Defines the camera the input is attached to.
  38365. */
  38366. camera: ArcRotateCamera;
  38367. /**
  38368. * Defines the list of key codes associated with the up action (increase alpha)
  38369. */
  38370. keysUp: number[];
  38371. /**
  38372. * Defines the list of key codes associated with the down action (decrease alpha)
  38373. */
  38374. keysDown: number[];
  38375. /**
  38376. * Defines the list of key codes associated with the left action (increase beta)
  38377. */
  38378. keysLeft: number[];
  38379. /**
  38380. * Defines the list of key codes associated with the right action (decrease beta)
  38381. */
  38382. keysRight: number[];
  38383. /**
  38384. * Defines the list of key codes associated with the reset action.
  38385. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38386. */
  38387. keysReset: number[];
  38388. /**
  38389. * Defines the panning sensibility of the inputs.
  38390. * (How fast is the camera panning)
  38391. */
  38392. panningSensibility: number;
  38393. /**
  38394. * Defines the zooming sensibility of the inputs.
  38395. * (How fast is the camera zooming)
  38396. */
  38397. zoomingSensibility: number;
  38398. /**
  38399. * Defines whether maintaining the alt key down switch the movement mode from
  38400. * orientation to zoom.
  38401. */
  38402. useAltToZoom: boolean;
  38403. /**
  38404. * Rotation speed of the camera
  38405. */
  38406. angularSpeed: number;
  38407. private _keys;
  38408. private _ctrlPressed;
  38409. private _altPressed;
  38410. private _onCanvasBlurObserver;
  38411. private _onKeyboardObserver;
  38412. private _engine;
  38413. private _scene;
  38414. /**
  38415. * Attach the input controls to a specific dom element to get the input from.
  38416. * @param element Defines the element the controls should be listened from
  38417. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38418. */
  38419. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38420. /**
  38421. * Detach the current controls from the specified dom element.
  38422. * @param element Defines the element to stop listening the inputs from
  38423. */
  38424. detachControl(element: Nullable<HTMLElement>): void;
  38425. /**
  38426. * Update the current camera state depending on the inputs that have been used this frame.
  38427. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38428. */
  38429. checkInputs(): void;
  38430. /**
  38431. * Gets the class name of the current intput.
  38432. * @returns the class name
  38433. */
  38434. getClassName(): string;
  38435. /**
  38436. * Get the friendly name associated with the input class.
  38437. * @returns the input friendly name
  38438. */
  38439. getSimpleName(): string;
  38440. }
  38441. }
  38442. declare module BABYLON {
  38443. /**
  38444. * Manage the mouse wheel inputs to control an arc rotate camera.
  38445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38446. */
  38447. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38448. /**
  38449. * Defines the camera the input is attached to.
  38450. */
  38451. camera: ArcRotateCamera;
  38452. /**
  38453. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38454. */
  38455. wheelPrecision: number;
  38456. /**
  38457. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38458. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38459. */
  38460. wheelDeltaPercentage: number;
  38461. private _wheel;
  38462. private _observer;
  38463. private computeDeltaFromMouseWheelLegacyEvent;
  38464. /**
  38465. * Attach the input controls to a specific dom element to get the input from.
  38466. * @param element Defines the element the controls should be listened from
  38467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38468. */
  38469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38470. /**
  38471. * Detach the current controls from the specified dom element.
  38472. * @param element Defines the element to stop listening the inputs from
  38473. */
  38474. detachControl(element: Nullable<HTMLElement>): void;
  38475. /**
  38476. * Gets the class name of the current intput.
  38477. * @returns the class name
  38478. */
  38479. getClassName(): string;
  38480. /**
  38481. * Get the friendly name associated with the input class.
  38482. * @returns the input friendly name
  38483. */
  38484. getSimpleName(): string;
  38485. }
  38486. }
  38487. declare module BABYLON {
  38488. /**
  38489. * Default Inputs manager for the ArcRotateCamera.
  38490. * It groups all the default supported inputs for ease of use.
  38491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38492. */
  38493. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38494. /**
  38495. * Instantiates a new ArcRotateCameraInputsManager.
  38496. * @param camera Defines the camera the inputs belong to
  38497. */
  38498. constructor(camera: ArcRotateCamera);
  38499. /**
  38500. * Add mouse wheel input support to the input manager.
  38501. * @returns the current input manager
  38502. */
  38503. addMouseWheel(): ArcRotateCameraInputsManager;
  38504. /**
  38505. * Add pointers input support to the input manager.
  38506. * @returns the current input manager
  38507. */
  38508. addPointers(): ArcRotateCameraInputsManager;
  38509. /**
  38510. * Add keyboard input support to the input manager.
  38511. * @returns the current input manager
  38512. */
  38513. addKeyboard(): ArcRotateCameraInputsManager;
  38514. }
  38515. }
  38516. declare module BABYLON {
  38517. /**
  38518. * This represents an orbital type of camera.
  38519. *
  38520. * 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.
  38521. * 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.
  38522. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38523. */
  38524. export class ArcRotateCamera extends TargetCamera {
  38525. /**
  38526. * Defines the rotation angle of the camera along the longitudinal axis.
  38527. */
  38528. alpha: number;
  38529. /**
  38530. * Defines the rotation angle of the camera along the latitudinal axis.
  38531. */
  38532. beta: number;
  38533. /**
  38534. * Defines the radius of the camera from it s target point.
  38535. */
  38536. radius: number;
  38537. protected _target: Vector3;
  38538. protected _targetHost: Nullable<AbstractMesh>;
  38539. /**
  38540. * Defines the target point of the camera.
  38541. * The camera looks towards it form the radius distance.
  38542. */
  38543. get target(): Vector3;
  38544. set target(value: Vector3);
  38545. /**
  38546. * Define the current local position of the camera in the scene
  38547. */
  38548. get position(): Vector3;
  38549. set position(newPosition: Vector3);
  38550. protected _upVector: Vector3;
  38551. protected _upToYMatrix: Matrix;
  38552. protected _YToUpMatrix: Matrix;
  38553. /**
  38554. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38555. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38556. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38557. */
  38558. set upVector(vec: Vector3);
  38559. get upVector(): Vector3;
  38560. /**
  38561. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38562. */
  38563. setMatUp(): void;
  38564. /**
  38565. * Current inertia value on the longitudinal axis.
  38566. * The bigger this number the longer it will take for the camera to stop.
  38567. */
  38568. inertialAlphaOffset: number;
  38569. /**
  38570. * Current inertia value on the latitudinal axis.
  38571. * The bigger this number the longer it will take for the camera to stop.
  38572. */
  38573. inertialBetaOffset: number;
  38574. /**
  38575. * Current inertia value on the radius axis.
  38576. * The bigger this number the longer it will take for the camera to stop.
  38577. */
  38578. inertialRadiusOffset: number;
  38579. /**
  38580. * Minimum allowed angle on the longitudinal axis.
  38581. * This can help limiting how the Camera is able to move in the scene.
  38582. */
  38583. lowerAlphaLimit: Nullable<number>;
  38584. /**
  38585. * Maximum allowed angle on the longitudinal axis.
  38586. * This can help limiting how the Camera is able to move in the scene.
  38587. */
  38588. upperAlphaLimit: Nullable<number>;
  38589. /**
  38590. * Minimum allowed angle on the latitudinal axis.
  38591. * This can help limiting how the Camera is able to move in the scene.
  38592. */
  38593. lowerBetaLimit: number;
  38594. /**
  38595. * Maximum allowed angle on the latitudinal axis.
  38596. * This can help limiting how the Camera is able to move in the scene.
  38597. */
  38598. upperBetaLimit: number;
  38599. /**
  38600. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38601. * This can help limiting how the Camera is able to move in the scene.
  38602. */
  38603. lowerRadiusLimit: Nullable<number>;
  38604. /**
  38605. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38606. * This can help limiting how the Camera is able to move in the scene.
  38607. */
  38608. upperRadiusLimit: Nullable<number>;
  38609. /**
  38610. * Defines the current inertia value used during panning of the camera along the X axis.
  38611. */
  38612. inertialPanningX: number;
  38613. /**
  38614. * Defines the current inertia value used during panning of the camera along the Y axis.
  38615. */
  38616. inertialPanningY: number;
  38617. /**
  38618. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38619. * Basically if your fingers moves away from more than this distance you will be considered
  38620. * in pinch mode.
  38621. */
  38622. pinchToPanMaxDistance: number;
  38623. /**
  38624. * Defines the maximum distance the camera can pan.
  38625. * This could help keeping the cammera always in your scene.
  38626. */
  38627. panningDistanceLimit: Nullable<number>;
  38628. /**
  38629. * Defines the target of the camera before paning.
  38630. */
  38631. panningOriginTarget: Vector3;
  38632. /**
  38633. * Defines the value of the inertia used during panning.
  38634. * 0 would mean stop inertia and one would mean no decelleration at all.
  38635. */
  38636. panningInertia: number;
  38637. /**
  38638. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38639. */
  38640. get angularSensibilityX(): number;
  38641. set angularSensibilityX(value: number);
  38642. /**
  38643. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38644. */
  38645. get angularSensibilityY(): number;
  38646. set angularSensibilityY(value: number);
  38647. /**
  38648. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38649. */
  38650. get pinchPrecision(): number;
  38651. set pinchPrecision(value: number);
  38652. /**
  38653. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38654. * It will be used instead of pinchDeltaPrecision if different from 0.
  38655. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38656. */
  38657. get pinchDeltaPercentage(): number;
  38658. set pinchDeltaPercentage(value: number);
  38659. /**
  38660. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38661. * and pinch delta percentage.
  38662. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38663. * that any object in the plane at the camera's target point will scale
  38664. * perfectly with finger motion.
  38665. */
  38666. get useNaturalPinchZoom(): boolean;
  38667. set useNaturalPinchZoom(value: boolean);
  38668. /**
  38669. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38670. */
  38671. get panningSensibility(): number;
  38672. set panningSensibility(value: number);
  38673. /**
  38674. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38675. */
  38676. get keysUp(): number[];
  38677. set keysUp(value: number[]);
  38678. /**
  38679. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38680. */
  38681. get keysDown(): number[];
  38682. set keysDown(value: number[]);
  38683. /**
  38684. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38685. */
  38686. get keysLeft(): number[];
  38687. set keysLeft(value: number[]);
  38688. /**
  38689. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38690. */
  38691. get keysRight(): number[];
  38692. set keysRight(value: number[]);
  38693. /**
  38694. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38695. */
  38696. get wheelPrecision(): number;
  38697. set wheelPrecision(value: number);
  38698. /**
  38699. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38700. * It will be used instead of pinchDeltaPrecision if different from 0.
  38701. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38702. */
  38703. get wheelDeltaPercentage(): number;
  38704. set wheelDeltaPercentage(value: number);
  38705. /**
  38706. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38707. */
  38708. zoomOnFactor: number;
  38709. /**
  38710. * Defines a screen offset for the camera position.
  38711. */
  38712. targetScreenOffset: Vector2;
  38713. /**
  38714. * Allows the camera to be completely reversed.
  38715. * If false the camera can not arrive upside down.
  38716. */
  38717. allowUpsideDown: boolean;
  38718. /**
  38719. * Define if double tap/click is used to restore the previously saved state of the camera.
  38720. */
  38721. useInputToRestoreState: boolean;
  38722. /** @hidden */
  38723. _viewMatrix: Matrix;
  38724. /** @hidden */
  38725. _useCtrlForPanning: boolean;
  38726. /** @hidden */
  38727. _panningMouseButton: number;
  38728. /**
  38729. * Defines the input associated to the camera.
  38730. */
  38731. inputs: ArcRotateCameraInputsManager;
  38732. /** @hidden */
  38733. _reset: () => void;
  38734. /**
  38735. * Defines the allowed panning axis.
  38736. */
  38737. panningAxis: Vector3;
  38738. protected _localDirection: Vector3;
  38739. protected _transformedDirection: Vector3;
  38740. private _bouncingBehavior;
  38741. /**
  38742. * Gets the bouncing behavior of the camera if it has been enabled.
  38743. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38744. */
  38745. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38746. /**
  38747. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38749. */
  38750. get useBouncingBehavior(): boolean;
  38751. set useBouncingBehavior(value: boolean);
  38752. private _framingBehavior;
  38753. /**
  38754. * Gets the framing behavior of the camera if it has been enabled.
  38755. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38756. */
  38757. get framingBehavior(): Nullable<FramingBehavior>;
  38758. /**
  38759. * Defines if the framing behavior of the camera is enabled on the camera.
  38760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38761. */
  38762. get useFramingBehavior(): boolean;
  38763. set useFramingBehavior(value: boolean);
  38764. private _autoRotationBehavior;
  38765. /**
  38766. * Gets the auto rotation behavior of the camera if it has been enabled.
  38767. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38768. */
  38769. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38770. /**
  38771. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38772. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38773. */
  38774. get useAutoRotationBehavior(): boolean;
  38775. set useAutoRotationBehavior(value: boolean);
  38776. /**
  38777. * Observable triggered when the mesh target has been changed on the camera.
  38778. */
  38779. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38780. /**
  38781. * Event raised when the camera is colliding with a mesh.
  38782. */
  38783. onCollide: (collidedMesh: AbstractMesh) => void;
  38784. /**
  38785. * Defines whether the camera should check collision with the objects oh the scene.
  38786. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38787. */
  38788. checkCollisions: boolean;
  38789. /**
  38790. * Defines the collision radius of the camera.
  38791. * This simulates a sphere around the camera.
  38792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38793. */
  38794. collisionRadius: Vector3;
  38795. protected _collider: Collider;
  38796. protected _previousPosition: Vector3;
  38797. protected _collisionVelocity: Vector3;
  38798. protected _newPosition: Vector3;
  38799. protected _previousAlpha: number;
  38800. protected _previousBeta: number;
  38801. protected _previousRadius: number;
  38802. protected _collisionTriggered: boolean;
  38803. protected _targetBoundingCenter: Nullable<Vector3>;
  38804. private _computationVector;
  38805. /**
  38806. * Instantiates a new ArcRotateCamera in a given scene
  38807. * @param name Defines the name of the camera
  38808. * @param alpha Defines the camera rotation along the logitudinal axis
  38809. * @param beta Defines the camera rotation along the latitudinal axis
  38810. * @param radius Defines the camera distance from its target
  38811. * @param target Defines the camera target
  38812. * @param scene Defines the scene the camera belongs to
  38813. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38814. */
  38815. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38816. /** @hidden */
  38817. _initCache(): void;
  38818. /** @hidden */
  38819. _updateCache(ignoreParentClass?: boolean): void;
  38820. protected _getTargetPosition(): Vector3;
  38821. private _storedAlpha;
  38822. private _storedBeta;
  38823. private _storedRadius;
  38824. private _storedTarget;
  38825. private _storedTargetScreenOffset;
  38826. /**
  38827. * Stores the current state of the camera (alpha, beta, radius and target)
  38828. * @returns the camera itself
  38829. */
  38830. storeState(): Camera;
  38831. /**
  38832. * @hidden
  38833. * Restored camera state. You must call storeState() first
  38834. */
  38835. _restoreStateValues(): boolean;
  38836. /** @hidden */
  38837. _isSynchronizedViewMatrix(): boolean;
  38838. /**
  38839. * Attached controls to the current camera.
  38840. * @param element Defines the element the controls should be listened from
  38841. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38842. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38843. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38844. */
  38845. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38846. /**
  38847. * Detach the current controls from the camera.
  38848. * The camera will stop reacting to inputs.
  38849. * @param element Defines the element to stop listening the inputs from
  38850. */
  38851. detachControl(element: HTMLElement): void;
  38852. /** @hidden */
  38853. _checkInputs(): void;
  38854. protected _checkLimits(): void;
  38855. /**
  38856. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38857. */
  38858. rebuildAnglesAndRadius(): void;
  38859. /**
  38860. * Use a position to define the current camera related information like alpha, beta and radius
  38861. * @param position Defines the position to set the camera at
  38862. */
  38863. setPosition(position: Vector3): void;
  38864. /**
  38865. * Defines the target the camera should look at.
  38866. * This will automatically adapt alpha beta and radius to fit within the new target.
  38867. * @param target Defines the new target as a Vector or a mesh
  38868. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38869. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38870. */
  38871. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38872. /** @hidden */
  38873. _getViewMatrix(): Matrix;
  38874. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38875. /**
  38876. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38877. * @param meshes Defines the mesh to zoom on
  38878. * @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)
  38879. */
  38880. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38881. /**
  38882. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38883. * The target will be changed but the radius
  38884. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38885. * @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)
  38886. */
  38887. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38888. min: Vector3;
  38889. max: Vector3;
  38890. distance: number;
  38891. }, doNotUpdateMaxZ?: boolean): void;
  38892. /**
  38893. * @override
  38894. * Override Camera.createRigCamera
  38895. */
  38896. createRigCamera(name: string, cameraIndex: number): Camera;
  38897. /**
  38898. * @hidden
  38899. * @override
  38900. * Override Camera._updateRigCameras
  38901. */
  38902. _updateRigCameras(): void;
  38903. /**
  38904. * Destroy the camera and release the current resources hold by it.
  38905. */
  38906. dispose(): void;
  38907. /**
  38908. * Gets the current object class name.
  38909. * @return the class name
  38910. */
  38911. getClassName(): string;
  38912. }
  38913. }
  38914. declare module BABYLON {
  38915. /**
  38916. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38917. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38918. */
  38919. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38920. /**
  38921. * Gets the name of the behavior.
  38922. */
  38923. get name(): string;
  38924. private _zoomStopsAnimation;
  38925. private _idleRotationSpeed;
  38926. private _idleRotationWaitTime;
  38927. private _idleRotationSpinupTime;
  38928. /**
  38929. * Sets the flag that indicates if user zooming should stop animation.
  38930. */
  38931. set zoomStopsAnimation(flag: boolean);
  38932. /**
  38933. * Gets the flag that indicates if user zooming should stop animation.
  38934. */
  38935. get zoomStopsAnimation(): boolean;
  38936. /**
  38937. * Sets the default speed at which the camera rotates around the model.
  38938. */
  38939. set idleRotationSpeed(speed: number);
  38940. /**
  38941. * Gets the default speed at which the camera rotates around the model.
  38942. */
  38943. get idleRotationSpeed(): number;
  38944. /**
  38945. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38946. */
  38947. set idleRotationWaitTime(time: number);
  38948. /**
  38949. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38950. */
  38951. get idleRotationWaitTime(): number;
  38952. /**
  38953. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38954. */
  38955. set idleRotationSpinupTime(time: number);
  38956. /**
  38957. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38958. */
  38959. get idleRotationSpinupTime(): number;
  38960. /**
  38961. * Gets a value indicating if the camera is currently rotating because of this behavior
  38962. */
  38963. get rotationInProgress(): boolean;
  38964. private _onPrePointerObservableObserver;
  38965. private _onAfterCheckInputsObserver;
  38966. private _attachedCamera;
  38967. private _isPointerDown;
  38968. private _lastFrameTime;
  38969. private _lastInteractionTime;
  38970. private _cameraRotationSpeed;
  38971. /**
  38972. * Initializes the behavior.
  38973. */
  38974. init(): void;
  38975. /**
  38976. * Attaches the behavior to its arc rotate camera.
  38977. * @param camera Defines the camera to attach the behavior to
  38978. */
  38979. attach(camera: ArcRotateCamera): void;
  38980. /**
  38981. * Detaches the behavior from its current arc rotate camera.
  38982. */
  38983. detach(): void;
  38984. /**
  38985. * Returns true if user is scrolling.
  38986. * @return true if user is scrolling.
  38987. */
  38988. private _userIsZooming;
  38989. private _lastFrameRadius;
  38990. private _shouldAnimationStopForInteraction;
  38991. /**
  38992. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38993. */
  38994. private _applyUserInteraction;
  38995. private _userIsMoving;
  38996. }
  38997. }
  38998. declare module BABYLON {
  38999. /**
  39000. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  39001. */
  39002. export class AttachToBoxBehavior implements Behavior<Mesh> {
  39003. private ui;
  39004. /**
  39005. * The name of the behavior
  39006. */
  39007. name: string;
  39008. /**
  39009. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39010. */
  39011. distanceAwayFromFace: number;
  39012. /**
  39013. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39014. */
  39015. distanceAwayFromBottomOfFace: number;
  39016. private _faceVectors;
  39017. private _target;
  39018. private _scene;
  39019. private _onRenderObserver;
  39020. private _tmpMatrix;
  39021. private _tmpVector;
  39022. /**
  39023. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39024. * @param ui The transform node that should be attched to the mesh
  39025. */
  39026. constructor(ui: TransformNode);
  39027. /**
  39028. * Initializes the behavior
  39029. */
  39030. init(): void;
  39031. private _closestFace;
  39032. private _zeroVector;
  39033. private _lookAtTmpMatrix;
  39034. private _lookAtToRef;
  39035. /**
  39036. * Attaches the AttachToBoxBehavior to the passed in mesh
  39037. * @param target The mesh that the specified node will be attached to
  39038. */
  39039. attach(target: Mesh): void;
  39040. /**
  39041. * Detaches the behavior from the mesh
  39042. */
  39043. detach(): void;
  39044. }
  39045. }
  39046. declare module BABYLON {
  39047. /**
  39048. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39049. */
  39050. export class FadeInOutBehavior implements Behavior<Mesh> {
  39051. /**
  39052. * Time in milliseconds to delay before fading in (Default: 0)
  39053. */
  39054. delay: number;
  39055. /**
  39056. * Time in milliseconds for the mesh to fade in (Default: 300)
  39057. */
  39058. fadeInTime: number;
  39059. private _millisecondsPerFrame;
  39060. private _hovered;
  39061. private _hoverValue;
  39062. private _ownerNode;
  39063. /**
  39064. * Instatiates the FadeInOutBehavior
  39065. */
  39066. constructor();
  39067. /**
  39068. * The name of the behavior
  39069. */
  39070. get name(): string;
  39071. /**
  39072. * Initializes the behavior
  39073. */
  39074. init(): void;
  39075. /**
  39076. * Attaches the fade behavior on the passed in mesh
  39077. * @param ownerNode The mesh that will be faded in/out once attached
  39078. */
  39079. attach(ownerNode: Mesh): void;
  39080. /**
  39081. * Detaches the behavior from the mesh
  39082. */
  39083. detach(): void;
  39084. /**
  39085. * Triggers the mesh to begin fading in or out
  39086. * @param value if the object should fade in or out (true to fade in)
  39087. */
  39088. fadeIn(value: boolean): void;
  39089. private _update;
  39090. private _setAllVisibility;
  39091. }
  39092. }
  39093. declare module BABYLON {
  39094. /**
  39095. * Class containing a set of static utilities functions for managing Pivots
  39096. * @hidden
  39097. */
  39098. export class PivotTools {
  39099. private static _PivotCached;
  39100. private static _OldPivotPoint;
  39101. private static _PivotTranslation;
  39102. private static _PivotTmpVector;
  39103. /** @hidden */
  39104. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39105. /** @hidden */
  39106. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39107. }
  39108. }
  39109. declare module BABYLON {
  39110. /**
  39111. * Class containing static functions to help procedurally build meshes
  39112. */
  39113. export class PlaneBuilder {
  39114. /**
  39115. * Creates a plane mesh
  39116. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39117. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39118. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39119. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39120. * * 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
  39121. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39122. * @param name defines the name of the mesh
  39123. * @param options defines the options used to create the mesh
  39124. * @param scene defines the hosting scene
  39125. * @returns the plane mesh
  39126. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39127. */
  39128. static CreatePlane(name: string, options: {
  39129. size?: number;
  39130. width?: number;
  39131. height?: number;
  39132. sideOrientation?: number;
  39133. frontUVs?: Vector4;
  39134. backUVs?: Vector4;
  39135. updatable?: boolean;
  39136. sourcePlane?: Plane;
  39137. }, scene?: Nullable<Scene>): Mesh;
  39138. }
  39139. }
  39140. declare module BABYLON {
  39141. /**
  39142. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39143. */
  39144. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39145. private static _AnyMouseID;
  39146. /**
  39147. * Abstract mesh the behavior is set on
  39148. */
  39149. attachedNode: AbstractMesh;
  39150. private _dragPlane;
  39151. private _scene;
  39152. private _pointerObserver;
  39153. private _beforeRenderObserver;
  39154. private static _planeScene;
  39155. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39156. /**
  39157. * 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)
  39158. */
  39159. maxDragAngle: number;
  39160. /**
  39161. * @hidden
  39162. */
  39163. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39164. /**
  39165. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39166. */
  39167. currentDraggingPointerID: number;
  39168. /**
  39169. * The last position where the pointer hit the drag plane in world space
  39170. */
  39171. lastDragPosition: Vector3;
  39172. /**
  39173. * If the behavior is currently in a dragging state
  39174. */
  39175. dragging: boolean;
  39176. /**
  39177. * 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)
  39178. */
  39179. dragDeltaRatio: number;
  39180. /**
  39181. * If the drag plane orientation should be updated during the dragging (Default: true)
  39182. */
  39183. updateDragPlane: boolean;
  39184. private _debugMode;
  39185. private _moving;
  39186. /**
  39187. * Fires each time the attached mesh is dragged with the pointer
  39188. * * delta between last drag position and current drag position in world space
  39189. * * dragDistance along the drag axis
  39190. * * dragPlaneNormal normal of the current drag plane used during the drag
  39191. * * dragPlanePoint in world space where the drag intersects the drag plane
  39192. */
  39193. onDragObservable: Observable<{
  39194. delta: Vector3;
  39195. dragPlanePoint: Vector3;
  39196. dragPlaneNormal: Vector3;
  39197. dragDistance: number;
  39198. pointerId: number;
  39199. }>;
  39200. /**
  39201. * Fires each time a drag begins (eg. mouse down on mesh)
  39202. */
  39203. onDragStartObservable: Observable<{
  39204. dragPlanePoint: Vector3;
  39205. pointerId: number;
  39206. }>;
  39207. /**
  39208. * Fires each time a drag ends (eg. mouse release after drag)
  39209. */
  39210. onDragEndObservable: Observable<{
  39211. dragPlanePoint: Vector3;
  39212. pointerId: number;
  39213. }>;
  39214. /**
  39215. * If the attached mesh should be moved when dragged
  39216. */
  39217. moveAttached: boolean;
  39218. /**
  39219. * If the drag behavior will react to drag events (Default: true)
  39220. */
  39221. enabled: boolean;
  39222. /**
  39223. * If pointer events should start and release the drag (Default: true)
  39224. */
  39225. startAndReleaseDragOnPointerEvents: boolean;
  39226. /**
  39227. * If camera controls should be detached during the drag
  39228. */
  39229. detachCameraControls: boolean;
  39230. /**
  39231. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39232. */
  39233. useObjectOrientationForDragging: boolean;
  39234. private _options;
  39235. /**
  39236. * Gets the options used by the behavior
  39237. */
  39238. get options(): {
  39239. dragAxis?: Vector3;
  39240. dragPlaneNormal?: Vector3;
  39241. };
  39242. /**
  39243. * Sets the options used by the behavior
  39244. */
  39245. set options(options: {
  39246. dragAxis?: Vector3;
  39247. dragPlaneNormal?: Vector3;
  39248. });
  39249. /**
  39250. * Creates a pointer drag behavior that can be attached to a mesh
  39251. * @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)
  39252. */
  39253. constructor(options?: {
  39254. dragAxis?: Vector3;
  39255. dragPlaneNormal?: Vector3;
  39256. });
  39257. /**
  39258. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39259. */
  39260. validateDrag: (targetPosition: Vector3) => boolean;
  39261. /**
  39262. * The name of the behavior
  39263. */
  39264. get name(): string;
  39265. /**
  39266. * Initializes the behavior
  39267. */
  39268. init(): void;
  39269. private _tmpVector;
  39270. private _alternatePickedPoint;
  39271. private _worldDragAxis;
  39272. private _targetPosition;
  39273. private _attachedElement;
  39274. /**
  39275. * Attaches the drag behavior the passed in mesh
  39276. * @param ownerNode The mesh that will be dragged around once attached
  39277. * @param predicate Predicate to use for pick filtering
  39278. */
  39279. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39280. /**
  39281. * Force relase the drag action by code.
  39282. */
  39283. releaseDrag(): void;
  39284. private _startDragRay;
  39285. private _lastPointerRay;
  39286. /**
  39287. * Simulates the start of a pointer drag event on the behavior
  39288. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39289. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39290. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39291. */
  39292. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39293. private _startDrag;
  39294. private _dragDelta;
  39295. private _moveDrag;
  39296. private _pickWithRayOnDragPlane;
  39297. private _pointA;
  39298. private _pointB;
  39299. private _pointC;
  39300. private _lineA;
  39301. private _lineB;
  39302. private _localAxis;
  39303. private _lookAt;
  39304. private _updateDragPlanePosition;
  39305. /**
  39306. * Detaches the behavior from the mesh
  39307. */
  39308. detach(): void;
  39309. }
  39310. }
  39311. declare module BABYLON {
  39312. /**
  39313. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39314. */
  39315. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39316. private _dragBehaviorA;
  39317. private _dragBehaviorB;
  39318. private _startDistance;
  39319. private _initialScale;
  39320. private _targetScale;
  39321. private _ownerNode;
  39322. private _sceneRenderObserver;
  39323. /**
  39324. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39325. */
  39326. constructor();
  39327. /**
  39328. * The name of the behavior
  39329. */
  39330. get name(): string;
  39331. /**
  39332. * Initializes the behavior
  39333. */
  39334. init(): void;
  39335. private _getCurrentDistance;
  39336. /**
  39337. * Attaches the scale behavior the passed in mesh
  39338. * @param ownerNode The mesh that will be scaled around once attached
  39339. */
  39340. attach(ownerNode: Mesh): void;
  39341. /**
  39342. * Detaches the behavior from the mesh
  39343. */
  39344. detach(): void;
  39345. }
  39346. }
  39347. declare module BABYLON {
  39348. /**
  39349. * 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
  39350. */
  39351. export class SixDofDragBehavior implements Behavior<Mesh> {
  39352. private static _virtualScene;
  39353. private _ownerNode;
  39354. private _sceneRenderObserver;
  39355. private _scene;
  39356. private _targetPosition;
  39357. private _virtualOriginMesh;
  39358. private _virtualDragMesh;
  39359. private _pointerObserver;
  39360. private _moving;
  39361. private _startingOrientation;
  39362. /**
  39363. * 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)
  39364. */
  39365. private zDragFactor;
  39366. /**
  39367. * If the object should rotate to face the drag origin
  39368. */
  39369. rotateDraggedObject: boolean;
  39370. /**
  39371. * If the behavior is currently in a dragging state
  39372. */
  39373. dragging: boolean;
  39374. /**
  39375. * 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)
  39376. */
  39377. dragDeltaRatio: number;
  39378. /**
  39379. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39380. */
  39381. currentDraggingPointerID: number;
  39382. /**
  39383. * If camera controls should be detached during the drag
  39384. */
  39385. detachCameraControls: boolean;
  39386. /**
  39387. * Fires each time a drag starts
  39388. */
  39389. onDragStartObservable: Observable<{}>;
  39390. /**
  39391. * Fires each time a drag ends (eg. mouse release after drag)
  39392. */
  39393. onDragEndObservable: Observable<{}>;
  39394. /**
  39395. * 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
  39396. */
  39397. constructor();
  39398. /**
  39399. * The name of the behavior
  39400. */
  39401. get name(): string;
  39402. /**
  39403. * Initializes the behavior
  39404. */
  39405. init(): void;
  39406. /**
  39407. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39408. */
  39409. private get _pointerCamera();
  39410. /**
  39411. * Attaches the scale behavior the passed in mesh
  39412. * @param ownerNode The mesh that will be scaled around once attached
  39413. */
  39414. attach(ownerNode: Mesh): void;
  39415. /**
  39416. * Detaches the behavior from the mesh
  39417. */
  39418. detach(): void;
  39419. }
  39420. }
  39421. declare module BABYLON {
  39422. /**
  39423. * Class used to apply inverse kinematics to bones
  39424. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39425. */
  39426. export class BoneIKController {
  39427. private static _tmpVecs;
  39428. private static _tmpQuat;
  39429. private static _tmpMats;
  39430. /**
  39431. * Gets or sets the target mesh
  39432. */
  39433. targetMesh: AbstractMesh;
  39434. /** Gets or sets the mesh used as pole */
  39435. poleTargetMesh: AbstractMesh;
  39436. /**
  39437. * Gets or sets the bone used as pole
  39438. */
  39439. poleTargetBone: Nullable<Bone>;
  39440. /**
  39441. * Gets or sets the target position
  39442. */
  39443. targetPosition: Vector3;
  39444. /**
  39445. * Gets or sets the pole target position
  39446. */
  39447. poleTargetPosition: Vector3;
  39448. /**
  39449. * Gets or sets the pole target local offset
  39450. */
  39451. poleTargetLocalOffset: Vector3;
  39452. /**
  39453. * Gets or sets the pole angle
  39454. */
  39455. poleAngle: number;
  39456. /**
  39457. * Gets or sets the mesh associated with the controller
  39458. */
  39459. mesh: AbstractMesh;
  39460. /**
  39461. * 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)
  39462. */
  39463. slerpAmount: number;
  39464. private _bone1Quat;
  39465. private _bone1Mat;
  39466. private _bone2Ang;
  39467. private _bone1;
  39468. private _bone2;
  39469. private _bone1Length;
  39470. private _bone2Length;
  39471. private _maxAngle;
  39472. private _maxReach;
  39473. private _rightHandedSystem;
  39474. private _bendAxis;
  39475. private _slerping;
  39476. private _adjustRoll;
  39477. /**
  39478. * Gets or sets maximum allowed angle
  39479. */
  39480. get maxAngle(): number;
  39481. set maxAngle(value: number);
  39482. /**
  39483. * Creates a new BoneIKController
  39484. * @param mesh defines the mesh to control
  39485. * @param bone defines the bone to control
  39486. * @param options defines options to set up the controller
  39487. */
  39488. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39489. targetMesh?: AbstractMesh;
  39490. poleTargetMesh?: AbstractMesh;
  39491. poleTargetBone?: Bone;
  39492. poleTargetLocalOffset?: Vector3;
  39493. poleAngle?: number;
  39494. bendAxis?: Vector3;
  39495. maxAngle?: number;
  39496. slerpAmount?: number;
  39497. });
  39498. private _setMaxAngle;
  39499. /**
  39500. * Force the controller to update the bones
  39501. */
  39502. update(): void;
  39503. }
  39504. }
  39505. declare module BABYLON {
  39506. /**
  39507. * Class used to make a bone look toward a point in space
  39508. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39509. */
  39510. export class BoneLookController {
  39511. private static _tmpVecs;
  39512. private static _tmpQuat;
  39513. private static _tmpMats;
  39514. /**
  39515. * The target Vector3 that the bone will look at
  39516. */
  39517. target: Vector3;
  39518. /**
  39519. * The mesh that the bone is attached to
  39520. */
  39521. mesh: AbstractMesh;
  39522. /**
  39523. * The bone that will be looking to the target
  39524. */
  39525. bone: Bone;
  39526. /**
  39527. * The up axis of the coordinate system that is used when the bone is rotated
  39528. */
  39529. upAxis: Vector3;
  39530. /**
  39531. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39532. */
  39533. upAxisSpace: Space;
  39534. /**
  39535. * Used to make an adjustment to the yaw of the bone
  39536. */
  39537. adjustYaw: number;
  39538. /**
  39539. * Used to make an adjustment to the pitch of the bone
  39540. */
  39541. adjustPitch: number;
  39542. /**
  39543. * Used to make an adjustment to the roll of the bone
  39544. */
  39545. adjustRoll: number;
  39546. /**
  39547. * 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)
  39548. */
  39549. slerpAmount: number;
  39550. private _minYaw;
  39551. private _maxYaw;
  39552. private _minPitch;
  39553. private _maxPitch;
  39554. private _minYawSin;
  39555. private _minYawCos;
  39556. private _maxYawSin;
  39557. private _maxYawCos;
  39558. private _midYawConstraint;
  39559. private _minPitchTan;
  39560. private _maxPitchTan;
  39561. private _boneQuat;
  39562. private _slerping;
  39563. private _transformYawPitch;
  39564. private _transformYawPitchInv;
  39565. private _firstFrameSkipped;
  39566. private _yawRange;
  39567. private _fowardAxis;
  39568. /**
  39569. * Gets or sets the minimum yaw angle that the bone can look to
  39570. */
  39571. get minYaw(): number;
  39572. set minYaw(value: number);
  39573. /**
  39574. * Gets or sets the maximum yaw angle that the bone can look to
  39575. */
  39576. get maxYaw(): number;
  39577. set maxYaw(value: number);
  39578. /**
  39579. * Gets or sets the minimum pitch angle that the bone can look to
  39580. */
  39581. get minPitch(): number;
  39582. set minPitch(value: number);
  39583. /**
  39584. * Gets or sets the maximum pitch angle that the bone can look to
  39585. */
  39586. get maxPitch(): number;
  39587. set maxPitch(value: number);
  39588. /**
  39589. * Create a BoneLookController
  39590. * @param mesh the mesh that the bone belongs to
  39591. * @param bone the bone that will be looking to the target
  39592. * @param target the target Vector3 to look at
  39593. * @param options optional settings:
  39594. * * maxYaw: the maximum angle the bone will yaw to
  39595. * * minYaw: the minimum angle the bone will yaw to
  39596. * * maxPitch: the maximum angle the bone will pitch to
  39597. * * minPitch: the minimum angle the bone will yaw to
  39598. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39599. * * upAxis: the up axis of the coordinate system
  39600. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39601. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39602. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39603. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39604. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39605. * * adjustRoll: used to make an adjustment to the roll of the bone
  39606. **/
  39607. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39608. maxYaw?: number;
  39609. minYaw?: number;
  39610. maxPitch?: number;
  39611. minPitch?: number;
  39612. slerpAmount?: number;
  39613. upAxis?: Vector3;
  39614. upAxisSpace?: Space;
  39615. yawAxis?: Vector3;
  39616. pitchAxis?: Vector3;
  39617. adjustYaw?: number;
  39618. adjustPitch?: number;
  39619. adjustRoll?: number;
  39620. });
  39621. /**
  39622. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39623. */
  39624. update(): void;
  39625. private _getAngleDiff;
  39626. private _getAngleBetween;
  39627. private _isAngleBetween;
  39628. }
  39629. }
  39630. declare module BABYLON {
  39631. /**
  39632. * Manage the gamepad inputs to control an arc rotate camera.
  39633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39634. */
  39635. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39636. /**
  39637. * Defines the camera the input is attached to.
  39638. */
  39639. camera: ArcRotateCamera;
  39640. /**
  39641. * Defines the gamepad the input is gathering event from.
  39642. */
  39643. gamepad: Nullable<Gamepad>;
  39644. /**
  39645. * Defines the gamepad rotation sensiblity.
  39646. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39647. */
  39648. gamepadRotationSensibility: number;
  39649. /**
  39650. * Defines the gamepad move sensiblity.
  39651. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39652. */
  39653. gamepadMoveSensibility: number;
  39654. private _yAxisScale;
  39655. /**
  39656. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39657. */
  39658. get invertYAxis(): boolean;
  39659. set invertYAxis(value: boolean);
  39660. private _onGamepadConnectedObserver;
  39661. private _onGamepadDisconnectedObserver;
  39662. /**
  39663. * Attach the input controls to a specific dom element to get the input from.
  39664. * @param element Defines the element the controls should be listened from
  39665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39666. */
  39667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39668. /**
  39669. * Detach the current controls from the specified dom element.
  39670. * @param element Defines the element to stop listening the inputs from
  39671. */
  39672. detachControl(element: Nullable<HTMLElement>): void;
  39673. /**
  39674. * Update the current camera state depending on the inputs that have been used this frame.
  39675. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39676. */
  39677. checkInputs(): void;
  39678. /**
  39679. * Gets the class name of the current intput.
  39680. * @returns the class name
  39681. */
  39682. getClassName(): string;
  39683. /**
  39684. * Get the friendly name associated with the input class.
  39685. * @returns the input friendly name
  39686. */
  39687. getSimpleName(): string;
  39688. }
  39689. }
  39690. declare module BABYLON {
  39691. interface ArcRotateCameraInputsManager {
  39692. /**
  39693. * Add orientation input support to the input manager.
  39694. * @returns the current input manager
  39695. */
  39696. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39697. }
  39698. /**
  39699. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39701. */
  39702. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39703. /**
  39704. * Defines the camera the input is attached to.
  39705. */
  39706. camera: ArcRotateCamera;
  39707. /**
  39708. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39709. */
  39710. alphaCorrection: number;
  39711. /**
  39712. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39713. */
  39714. gammaCorrection: number;
  39715. private _alpha;
  39716. private _gamma;
  39717. private _dirty;
  39718. private _deviceOrientationHandler;
  39719. /**
  39720. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39721. */
  39722. constructor();
  39723. /**
  39724. * Attach the input controls to a specific dom element to get the input from.
  39725. * @param element Defines the element the controls should be listened from
  39726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39727. */
  39728. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39729. /** @hidden */
  39730. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39731. /**
  39732. * Update the current camera state depending on the inputs that have been used this frame.
  39733. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39734. */
  39735. checkInputs(): void;
  39736. /**
  39737. * Detach the current controls from the specified dom element.
  39738. * @param element Defines the element to stop listening the inputs from
  39739. */
  39740. detachControl(element: Nullable<HTMLElement>): void;
  39741. /**
  39742. * Gets the class name of the current intput.
  39743. * @returns the class name
  39744. */
  39745. getClassName(): string;
  39746. /**
  39747. * Get the friendly name associated with the input class.
  39748. * @returns the input friendly name
  39749. */
  39750. getSimpleName(): string;
  39751. }
  39752. }
  39753. declare module BABYLON {
  39754. /**
  39755. * Listen to mouse events to control the camera.
  39756. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39757. */
  39758. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39759. /**
  39760. * Defines the camera the input is attached to.
  39761. */
  39762. camera: FlyCamera;
  39763. /**
  39764. * Defines if touch is enabled. (Default is true.)
  39765. */
  39766. touchEnabled: boolean;
  39767. /**
  39768. * Defines the buttons associated with the input to handle camera rotation.
  39769. */
  39770. buttons: number[];
  39771. /**
  39772. * Assign buttons for Yaw control.
  39773. */
  39774. buttonsYaw: number[];
  39775. /**
  39776. * Assign buttons for Pitch control.
  39777. */
  39778. buttonsPitch: number[];
  39779. /**
  39780. * Assign buttons for Roll control.
  39781. */
  39782. buttonsRoll: number[];
  39783. /**
  39784. * Detect if any button is being pressed while mouse is moved.
  39785. * -1 = Mouse locked.
  39786. * 0 = Left button.
  39787. * 1 = Middle Button.
  39788. * 2 = Right Button.
  39789. */
  39790. activeButton: number;
  39791. /**
  39792. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39793. * Higher values reduce its sensitivity.
  39794. */
  39795. angularSensibility: number;
  39796. private _mousemoveCallback;
  39797. private _observer;
  39798. private _rollObserver;
  39799. private previousPosition;
  39800. private noPreventDefault;
  39801. private element;
  39802. /**
  39803. * Listen to mouse events to control the camera.
  39804. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39806. */
  39807. constructor(touchEnabled?: boolean);
  39808. /**
  39809. * Attach the mouse control to the HTML DOM element.
  39810. * @param element Defines the element that listens to the input events.
  39811. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39812. */
  39813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39814. /**
  39815. * Detach the current controls from the specified dom element.
  39816. * @param element Defines the element to stop listening the inputs from
  39817. */
  39818. detachControl(element: Nullable<HTMLElement>): void;
  39819. /**
  39820. * Gets the class name of the current input.
  39821. * @returns the class name.
  39822. */
  39823. getClassName(): string;
  39824. /**
  39825. * Get the friendly name associated with the input class.
  39826. * @returns the input's friendly name.
  39827. */
  39828. getSimpleName(): string;
  39829. private _pointerInput;
  39830. private _onMouseMove;
  39831. /**
  39832. * Rotate camera by mouse offset.
  39833. */
  39834. private rotateCamera;
  39835. }
  39836. }
  39837. declare module BABYLON {
  39838. /**
  39839. * Default Inputs manager for the FlyCamera.
  39840. * It groups all the default supported inputs for ease of use.
  39841. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39842. */
  39843. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39844. /**
  39845. * Instantiates a new FlyCameraInputsManager.
  39846. * @param camera Defines the camera the inputs belong to.
  39847. */
  39848. constructor(camera: FlyCamera);
  39849. /**
  39850. * Add keyboard input support to the input manager.
  39851. * @returns the new FlyCameraKeyboardMoveInput().
  39852. */
  39853. addKeyboard(): FlyCameraInputsManager;
  39854. /**
  39855. * Add mouse input support to the input manager.
  39856. * @param touchEnabled Enable touch screen support.
  39857. * @returns the new FlyCameraMouseInput().
  39858. */
  39859. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39860. }
  39861. }
  39862. declare module BABYLON {
  39863. /**
  39864. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39865. * such as in a 3D Space Shooter or a Flight Simulator.
  39866. */
  39867. export class FlyCamera extends TargetCamera {
  39868. /**
  39869. * Define the collision ellipsoid of the camera.
  39870. * This is helpful for simulating a camera body, like a player's body.
  39871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39872. */
  39873. ellipsoid: Vector3;
  39874. /**
  39875. * Define an offset for the position of the ellipsoid around the camera.
  39876. * This can be helpful if the camera is attached away from the player's body center,
  39877. * such as at its head.
  39878. */
  39879. ellipsoidOffset: Vector3;
  39880. /**
  39881. * Enable or disable collisions of the camera with the rest of the scene objects.
  39882. */
  39883. checkCollisions: boolean;
  39884. /**
  39885. * Enable or disable gravity on the camera.
  39886. */
  39887. applyGravity: boolean;
  39888. /**
  39889. * Define the current direction the camera is moving to.
  39890. */
  39891. cameraDirection: Vector3;
  39892. /**
  39893. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39894. * This overrides and empties cameraRotation.
  39895. */
  39896. rotationQuaternion: Quaternion;
  39897. /**
  39898. * Track Roll to maintain the wanted Rolling when looking around.
  39899. */
  39900. _trackRoll: number;
  39901. /**
  39902. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39903. */
  39904. rollCorrect: number;
  39905. /**
  39906. * Mimic a banked turn, Rolling the camera when Yawing.
  39907. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39908. */
  39909. bankedTurn: boolean;
  39910. /**
  39911. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39912. */
  39913. bankedTurnLimit: number;
  39914. /**
  39915. * Value of 0 disables the banked Roll.
  39916. * Value of 1 is equal to the Yaw angle in radians.
  39917. */
  39918. bankedTurnMultiplier: number;
  39919. /**
  39920. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39921. */
  39922. inputs: FlyCameraInputsManager;
  39923. /**
  39924. * Gets the input sensibility for mouse input.
  39925. * Higher values reduce sensitivity.
  39926. */
  39927. get angularSensibility(): number;
  39928. /**
  39929. * Sets the input sensibility for a mouse input.
  39930. * Higher values reduce sensitivity.
  39931. */
  39932. set angularSensibility(value: number);
  39933. /**
  39934. * Get the keys for camera movement forward.
  39935. */
  39936. get keysForward(): number[];
  39937. /**
  39938. * Set the keys for camera movement forward.
  39939. */
  39940. set keysForward(value: number[]);
  39941. /**
  39942. * Get the keys for camera movement backward.
  39943. */
  39944. get keysBackward(): number[];
  39945. set keysBackward(value: number[]);
  39946. /**
  39947. * Get the keys for camera movement up.
  39948. */
  39949. get keysUp(): number[];
  39950. /**
  39951. * Set the keys for camera movement up.
  39952. */
  39953. set keysUp(value: number[]);
  39954. /**
  39955. * Get the keys for camera movement down.
  39956. */
  39957. get keysDown(): number[];
  39958. /**
  39959. * Set the keys for camera movement down.
  39960. */
  39961. set keysDown(value: number[]);
  39962. /**
  39963. * Get the keys for camera movement left.
  39964. */
  39965. get keysLeft(): number[];
  39966. /**
  39967. * Set the keys for camera movement left.
  39968. */
  39969. set keysLeft(value: number[]);
  39970. /**
  39971. * Set the keys for camera movement right.
  39972. */
  39973. get keysRight(): number[];
  39974. /**
  39975. * Set the keys for camera movement right.
  39976. */
  39977. set keysRight(value: number[]);
  39978. /**
  39979. * Event raised when the camera collides with a mesh in the scene.
  39980. */
  39981. onCollide: (collidedMesh: AbstractMesh) => void;
  39982. private _collider;
  39983. private _needMoveForGravity;
  39984. private _oldPosition;
  39985. private _diffPosition;
  39986. private _newPosition;
  39987. /** @hidden */
  39988. _localDirection: Vector3;
  39989. /** @hidden */
  39990. _transformedDirection: Vector3;
  39991. /**
  39992. * Instantiates a FlyCamera.
  39993. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39994. * such as in a 3D Space Shooter or a Flight Simulator.
  39995. * @param name Define the name of the camera in the scene.
  39996. * @param position Define the starting position of the camera in the scene.
  39997. * @param scene Define the scene the camera belongs to.
  39998. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39999. */
  40000. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40001. /**
  40002. * Attach a control to the HTML DOM element.
  40003. * @param element Defines the element that listens to the input events.
  40004. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  40005. */
  40006. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40007. /**
  40008. * Detach a control from the HTML DOM element.
  40009. * The camera will stop reacting to that input.
  40010. * @param element Defines the element that listens to the input events.
  40011. */
  40012. detachControl(element: HTMLElement): void;
  40013. private _collisionMask;
  40014. /**
  40015. * Get the mask that the camera ignores in collision events.
  40016. */
  40017. get collisionMask(): number;
  40018. /**
  40019. * Set the mask that the camera ignores in collision events.
  40020. */
  40021. set collisionMask(mask: number);
  40022. /** @hidden */
  40023. _collideWithWorld(displacement: Vector3): void;
  40024. /** @hidden */
  40025. private _onCollisionPositionChange;
  40026. /** @hidden */
  40027. _checkInputs(): void;
  40028. /** @hidden */
  40029. _decideIfNeedsToMove(): boolean;
  40030. /** @hidden */
  40031. _updatePosition(): void;
  40032. /**
  40033. * Restore the Roll to its target value at the rate specified.
  40034. * @param rate - Higher means slower restoring.
  40035. * @hidden
  40036. */
  40037. restoreRoll(rate: number): void;
  40038. /**
  40039. * Destroy the camera and release the current resources held by it.
  40040. */
  40041. dispose(): void;
  40042. /**
  40043. * Get the current object class name.
  40044. * @returns the class name.
  40045. */
  40046. getClassName(): string;
  40047. }
  40048. }
  40049. declare module BABYLON {
  40050. /**
  40051. * Listen to keyboard events to control the camera.
  40052. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40053. */
  40054. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40055. /**
  40056. * Defines the camera the input is attached to.
  40057. */
  40058. camera: FlyCamera;
  40059. /**
  40060. * The list of keyboard keys used to control the forward move of the camera.
  40061. */
  40062. keysForward: number[];
  40063. /**
  40064. * The list of keyboard keys used to control the backward move of the camera.
  40065. */
  40066. keysBackward: number[];
  40067. /**
  40068. * The list of keyboard keys used to control the forward move of the camera.
  40069. */
  40070. keysUp: number[];
  40071. /**
  40072. * The list of keyboard keys used to control the backward move of the camera.
  40073. */
  40074. keysDown: number[];
  40075. /**
  40076. * The list of keyboard keys used to control the right strafe move of the camera.
  40077. */
  40078. keysRight: number[];
  40079. /**
  40080. * The list of keyboard keys used to control the left strafe move of the camera.
  40081. */
  40082. keysLeft: number[];
  40083. private _keys;
  40084. private _onCanvasBlurObserver;
  40085. private _onKeyboardObserver;
  40086. private _engine;
  40087. private _scene;
  40088. /**
  40089. * Attach the input controls to a specific dom element to get the input from.
  40090. * @param element Defines the element the controls should be listened from
  40091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40092. */
  40093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40094. /**
  40095. * Detach the current controls from the specified dom element.
  40096. * @param element Defines the element to stop listening the inputs from
  40097. */
  40098. detachControl(element: Nullable<HTMLElement>): void;
  40099. /**
  40100. * Gets the class name of the current intput.
  40101. * @returns the class name
  40102. */
  40103. getClassName(): string;
  40104. /** @hidden */
  40105. _onLostFocus(e: FocusEvent): void;
  40106. /**
  40107. * Get the friendly name associated with the input class.
  40108. * @returns the input friendly name
  40109. */
  40110. getSimpleName(): string;
  40111. /**
  40112. * Update the current camera state depending on the inputs that have been used this frame.
  40113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40114. */
  40115. checkInputs(): void;
  40116. }
  40117. }
  40118. declare module BABYLON {
  40119. /**
  40120. * Manage the mouse wheel inputs to control a follow camera.
  40121. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40122. */
  40123. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40124. /**
  40125. * Defines the camera the input is attached to.
  40126. */
  40127. camera: FollowCamera;
  40128. /**
  40129. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40130. */
  40131. axisControlRadius: boolean;
  40132. /**
  40133. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40134. */
  40135. axisControlHeight: boolean;
  40136. /**
  40137. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40138. */
  40139. axisControlRotation: boolean;
  40140. /**
  40141. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40142. * relation to mouseWheel events.
  40143. */
  40144. wheelPrecision: number;
  40145. /**
  40146. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40147. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40148. */
  40149. wheelDeltaPercentage: number;
  40150. private _wheel;
  40151. private _observer;
  40152. /**
  40153. * Attach the input controls to a specific dom element to get the input from.
  40154. * @param element Defines the element the controls should be listened from
  40155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40156. */
  40157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40158. /**
  40159. * Detach the current controls from the specified dom element.
  40160. * @param element Defines the element to stop listening the inputs from
  40161. */
  40162. detachControl(element: Nullable<HTMLElement>): void;
  40163. /**
  40164. * Gets the class name of the current intput.
  40165. * @returns the class name
  40166. */
  40167. getClassName(): string;
  40168. /**
  40169. * Get the friendly name associated with the input class.
  40170. * @returns the input friendly name
  40171. */
  40172. getSimpleName(): string;
  40173. }
  40174. }
  40175. declare module BABYLON {
  40176. /**
  40177. * Manage the pointers inputs to control an follow camera.
  40178. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40179. */
  40180. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40181. /**
  40182. * Defines the camera the input is attached to.
  40183. */
  40184. camera: FollowCamera;
  40185. /**
  40186. * Gets the class name of the current input.
  40187. * @returns the class name
  40188. */
  40189. getClassName(): string;
  40190. /**
  40191. * Defines the pointer angular sensibility along the X axis or how fast is
  40192. * the camera rotating.
  40193. * A negative number will reverse the axis direction.
  40194. */
  40195. angularSensibilityX: number;
  40196. /**
  40197. * Defines the pointer angular sensibility along the Y axis or how fast is
  40198. * the camera rotating.
  40199. * A negative number will reverse the axis direction.
  40200. */
  40201. angularSensibilityY: number;
  40202. /**
  40203. * Defines the pointer pinch precision or how fast is the camera zooming.
  40204. * A negative number will reverse the axis direction.
  40205. */
  40206. pinchPrecision: number;
  40207. /**
  40208. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40209. * from 0.
  40210. * It defines the percentage of current camera.radius to use as delta when
  40211. * pinch zoom is used.
  40212. */
  40213. pinchDeltaPercentage: number;
  40214. /**
  40215. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40216. */
  40217. axisXControlRadius: boolean;
  40218. /**
  40219. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40220. */
  40221. axisXControlHeight: boolean;
  40222. /**
  40223. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40224. */
  40225. axisXControlRotation: boolean;
  40226. /**
  40227. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40228. */
  40229. axisYControlRadius: boolean;
  40230. /**
  40231. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40232. */
  40233. axisYControlHeight: boolean;
  40234. /**
  40235. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40236. */
  40237. axisYControlRotation: boolean;
  40238. /**
  40239. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40240. */
  40241. axisPinchControlRadius: boolean;
  40242. /**
  40243. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40244. */
  40245. axisPinchControlHeight: boolean;
  40246. /**
  40247. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40248. */
  40249. axisPinchControlRotation: boolean;
  40250. /**
  40251. * Log error messages if basic misconfiguration has occurred.
  40252. */
  40253. warningEnable: boolean;
  40254. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40255. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40256. private _warningCounter;
  40257. private _warning;
  40258. }
  40259. }
  40260. declare module BABYLON {
  40261. /**
  40262. * Default Inputs manager for the FollowCamera.
  40263. * It groups all the default supported inputs for ease of use.
  40264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40265. */
  40266. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40267. /**
  40268. * Instantiates a new FollowCameraInputsManager.
  40269. * @param camera Defines the camera the inputs belong to
  40270. */
  40271. constructor(camera: FollowCamera);
  40272. /**
  40273. * Add keyboard input support to the input manager.
  40274. * @returns the current input manager
  40275. */
  40276. addKeyboard(): FollowCameraInputsManager;
  40277. /**
  40278. * Add mouse wheel input support to the input manager.
  40279. * @returns the current input manager
  40280. */
  40281. addMouseWheel(): FollowCameraInputsManager;
  40282. /**
  40283. * Add pointers input support to the input manager.
  40284. * @returns the current input manager
  40285. */
  40286. addPointers(): FollowCameraInputsManager;
  40287. /**
  40288. * Add orientation input support to the input manager.
  40289. * @returns the current input manager
  40290. */
  40291. addVRDeviceOrientation(): FollowCameraInputsManager;
  40292. }
  40293. }
  40294. declare module BABYLON {
  40295. /**
  40296. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40297. * an arc rotate version arcFollowCamera are available.
  40298. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40299. */
  40300. export class FollowCamera extends TargetCamera {
  40301. /**
  40302. * Distance the follow camera should follow an object at
  40303. */
  40304. radius: number;
  40305. /**
  40306. * Minimum allowed distance of the camera to the axis of rotation
  40307. * (The camera can not get closer).
  40308. * This can help limiting how the Camera is able to move in the scene.
  40309. */
  40310. lowerRadiusLimit: Nullable<number>;
  40311. /**
  40312. * Maximum allowed distance of the camera to the axis of rotation
  40313. * (The camera can not get further).
  40314. * This can help limiting how the Camera is able to move in the scene.
  40315. */
  40316. upperRadiusLimit: Nullable<number>;
  40317. /**
  40318. * Define a rotation offset between the camera and the object it follows
  40319. */
  40320. rotationOffset: number;
  40321. /**
  40322. * Minimum allowed angle to camera position relative to target object.
  40323. * This can help limiting how the Camera is able to move in the scene.
  40324. */
  40325. lowerRotationOffsetLimit: Nullable<number>;
  40326. /**
  40327. * Maximum allowed angle to camera position relative to target object.
  40328. * This can help limiting how the Camera is able to move in the scene.
  40329. */
  40330. upperRotationOffsetLimit: Nullable<number>;
  40331. /**
  40332. * Define a height offset between the camera and the object it follows.
  40333. * It can help following an object from the top (like a car chaing a plane)
  40334. */
  40335. heightOffset: number;
  40336. /**
  40337. * Minimum allowed height of camera position relative to target object.
  40338. * This can help limiting how the Camera is able to move in the scene.
  40339. */
  40340. lowerHeightOffsetLimit: Nullable<number>;
  40341. /**
  40342. * Maximum allowed height of camera position relative to target object.
  40343. * This can help limiting how the Camera is able to move in the scene.
  40344. */
  40345. upperHeightOffsetLimit: Nullable<number>;
  40346. /**
  40347. * Define how fast the camera can accelerate to follow it s target.
  40348. */
  40349. cameraAcceleration: number;
  40350. /**
  40351. * Define the speed limit of the camera following an object.
  40352. */
  40353. maxCameraSpeed: number;
  40354. /**
  40355. * Define the target of the camera.
  40356. */
  40357. lockedTarget: Nullable<AbstractMesh>;
  40358. /**
  40359. * Defines the input associated with the camera.
  40360. */
  40361. inputs: FollowCameraInputsManager;
  40362. /**
  40363. * Instantiates the follow camera.
  40364. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40365. * @param name Define the name of the camera in the scene
  40366. * @param position Define the position of the camera
  40367. * @param scene Define the scene the camera belong to
  40368. * @param lockedTarget Define the target of the camera
  40369. */
  40370. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40371. private _follow;
  40372. /**
  40373. * Attached controls to the current camera.
  40374. * @param element Defines the element the controls should be listened from
  40375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40376. */
  40377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40378. /**
  40379. * Detach the current controls from the camera.
  40380. * The camera will stop reacting to inputs.
  40381. * @param element Defines the element to stop listening the inputs from
  40382. */
  40383. detachControl(element: HTMLElement): void;
  40384. /** @hidden */
  40385. _checkInputs(): void;
  40386. private _checkLimits;
  40387. /**
  40388. * Gets the camera class name.
  40389. * @returns the class name
  40390. */
  40391. getClassName(): string;
  40392. }
  40393. /**
  40394. * Arc Rotate version of the follow camera.
  40395. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40396. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40397. */
  40398. export class ArcFollowCamera extends TargetCamera {
  40399. /** The longitudinal angle of the camera */
  40400. alpha: number;
  40401. /** The latitudinal angle of the camera */
  40402. beta: number;
  40403. /** The radius of the camera from its target */
  40404. radius: number;
  40405. /** Define the camera target (the messh it should follow) */
  40406. target: Nullable<AbstractMesh>;
  40407. private _cartesianCoordinates;
  40408. /**
  40409. * Instantiates a new ArcFollowCamera
  40410. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40411. * @param name Define the name of the camera
  40412. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40413. * @param beta Define the rotation angle of the camera around the elevation axis
  40414. * @param radius Define the radius of the camera from its target point
  40415. * @param target Define the target of the camera
  40416. * @param scene Define the scene the camera belongs to
  40417. */
  40418. constructor(name: string,
  40419. /** The longitudinal angle of the camera */
  40420. alpha: number,
  40421. /** The latitudinal angle of the camera */
  40422. beta: number,
  40423. /** The radius of the camera from its target */
  40424. radius: number,
  40425. /** Define the camera target (the messh it should follow) */
  40426. target: Nullable<AbstractMesh>, scene: Scene);
  40427. private _follow;
  40428. /** @hidden */
  40429. _checkInputs(): void;
  40430. /**
  40431. * Returns the class name of the object.
  40432. * It is mostly used internally for serialization purposes.
  40433. */
  40434. getClassName(): string;
  40435. }
  40436. }
  40437. declare module BABYLON {
  40438. /**
  40439. * Manage the keyboard inputs to control the movement of a follow camera.
  40440. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40441. */
  40442. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40443. /**
  40444. * Defines the camera the input is attached to.
  40445. */
  40446. camera: FollowCamera;
  40447. /**
  40448. * Defines the list of key codes associated with the up action (increase heightOffset)
  40449. */
  40450. keysHeightOffsetIncr: number[];
  40451. /**
  40452. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40453. */
  40454. keysHeightOffsetDecr: number[];
  40455. /**
  40456. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40457. */
  40458. keysHeightOffsetModifierAlt: boolean;
  40459. /**
  40460. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40461. */
  40462. keysHeightOffsetModifierCtrl: boolean;
  40463. /**
  40464. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40465. */
  40466. keysHeightOffsetModifierShift: boolean;
  40467. /**
  40468. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40469. */
  40470. keysRotationOffsetIncr: number[];
  40471. /**
  40472. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40473. */
  40474. keysRotationOffsetDecr: number[];
  40475. /**
  40476. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40477. */
  40478. keysRotationOffsetModifierAlt: boolean;
  40479. /**
  40480. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40481. */
  40482. keysRotationOffsetModifierCtrl: boolean;
  40483. /**
  40484. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40485. */
  40486. keysRotationOffsetModifierShift: boolean;
  40487. /**
  40488. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40489. */
  40490. keysRadiusIncr: number[];
  40491. /**
  40492. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40493. */
  40494. keysRadiusDecr: number[];
  40495. /**
  40496. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40497. */
  40498. keysRadiusModifierAlt: boolean;
  40499. /**
  40500. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40501. */
  40502. keysRadiusModifierCtrl: boolean;
  40503. /**
  40504. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40505. */
  40506. keysRadiusModifierShift: boolean;
  40507. /**
  40508. * Defines the rate of change of heightOffset.
  40509. */
  40510. heightSensibility: number;
  40511. /**
  40512. * Defines the rate of change of rotationOffset.
  40513. */
  40514. rotationSensibility: number;
  40515. /**
  40516. * Defines the rate of change of radius.
  40517. */
  40518. radiusSensibility: number;
  40519. private _keys;
  40520. private _ctrlPressed;
  40521. private _altPressed;
  40522. private _shiftPressed;
  40523. private _onCanvasBlurObserver;
  40524. private _onKeyboardObserver;
  40525. private _engine;
  40526. private _scene;
  40527. /**
  40528. * Attach the input controls to a specific dom element to get the input from.
  40529. * @param element Defines the element the controls should be listened from
  40530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40531. */
  40532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40533. /**
  40534. * Detach the current controls from the specified dom element.
  40535. * @param element Defines the element to stop listening the inputs from
  40536. */
  40537. detachControl(element: Nullable<HTMLElement>): void;
  40538. /**
  40539. * Update the current camera state depending on the inputs that have been used this frame.
  40540. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40541. */
  40542. checkInputs(): void;
  40543. /**
  40544. * Gets the class name of the current input.
  40545. * @returns the class name
  40546. */
  40547. getClassName(): string;
  40548. /**
  40549. * Get the friendly name associated with the input class.
  40550. * @returns the input friendly name
  40551. */
  40552. getSimpleName(): string;
  40553. /**
  40554. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40555. * allow modification of the heightOffset value.
  40556. */
  40557. private _modifierHeightOffset;
  40558. /**
  40559. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40560. * allow modification of the rotationOffset value.
  40561. */
  40562. private _modifierRotationOffset;
  40563. /**
  40564. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40565. * allow modification of the radius value.
  40566. */
  40567. private _modifierRadius;
  40568. }
  40569. }
  40570. declare module BABYLON {
  40571. interface FreeCameraInputsManager {
  40572. /**
  40573. * @hidden
  40574. */
  40575. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40576. /**
  40577. * Add orientation input support to the input manager.
  40578. * @returns the current input manager
  40579. */
  40580. addDeviceOrientation(): FreeCameraInputsManager;
  40581. }
  40582. /**
  40583. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40584. * Screen rotation is taken into account.
  40585. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40586. */
  40587. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40588. private _camera;
  40589. private _screenOrientationAngle;
  40590. private _constantTranform;
  40591. private _screenQuaternion;
  40592. private _alpha;
  40593. private _beta;
  40594. private _gamma;
  40595. /**
  40596. * Can be used to detect if a device orientation sensor is available on a device
  40597. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40598. * @returns a promise that will resolve on orientation change
  40599. */
  40600. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40601. /**
  40602. * @hidden
  40603. */
  40604. _onDeviceOrientationChangedObservable: Observable<void>;
  40605. /**
  40606. * Instantiates a new input
  40607. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40608. */
  40609. constructor();
  40610. /**
  40611. * Define the camera controlled by the input.
  40612. */
  40613. get camera(): FreeCamera;
  40614. set camera(camera: FreeCamera);
  40615. /**
  40616. * Attach the input controls to a specific dom element to get the input from.
  40617. * @param element Defines the element the controls should be listened from
  40618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40619. */
  40620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40621. private _orientationChanged;
  40622. private _deviceOrientation;
  40623. /**
  40624. * Detach the current controls from the specified dom element.
  40625. * @param element Defines the element to stop listening the inputs from
  40626. */
  40627. detachControl(element: Nullable<HTMLElement>): void;
  40628. /**
  40629. * Update the current camera state depending on the inputs that have been used this frame.
  40630. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40631. */
  40632. checkInputs(): void;
  40633. /**
  40634. * Gets the class name of the current intput.
  40635. * @returns the class name
  40636. */
  40637. getClassName(): string;
  40638. /**
  40639. * Get the friendly name associated with the input class.
  40640. * @returns the input friendly name
  40641. */
  40642. getSimpleName(): string;
  40643. }
  40644. }
  40645. declare module BABYLON {
  40646. /**
  40647. * Manage the gamepad inputs to control a free camera.
  40648. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40649. */
  40650. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40651. /**
  40652. * Define the camera the input is attached to.
  40653. */
  40654. camera: FreeCamera;
  40655. /**
  40656. * Define the Gamepad controlling the input
  40657. */
  40658. gamepad: Nullable<Gamepad>;
  40659. /**
  40660. * Defines the gamepad rotation sensiblity.
  40661. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40662. */
  40663. gamepadAngularSensibility: number;
  40664. /**
  40665. * Defines the gamepad move sensiblity.
  40666. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40667. */
  40668. gamepadMoveSensibility: number;
  40669. private _yAxisScale;
  40670. /**
  40671. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40672. */
  40673. get invertYAxis(): boolean;
  40674. set invertYAxis(value: boolean);
  40675. private _onGamepadConnectedObserver;
  40676. private _onGamepadDisconnectedObserver;
  40677. private _cameraTransform;
  40678. private _deltaTransform;
  40679. private _vector3;
  40680. private _vector2;
  40681. /**
  40682. * Attach the input controls to a specific dom element to get the input from.
  40683. * @param element Defines the element the controls should be listened from
  40684. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40685. */
  40686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40687. /**
  40688. * Detach the current controls from the specified dom element.
  40689. * @param element Defines the element to stop listening the inputs from
  40690. */
  40691. detachControl(element: Nullable<HTMLElement>): void;
  40692. /**
  40693. * Update the current camera state depending on the inputs that have been used this frame.
  40694. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40695. */
  40696. checkInputs(): void;
  40697. /**
  40698. * Gets the class name of the current intput.
  40699. * @returns the class name
  40700. */
  40701. getClassName(): string;
  40702. /**
  40703. * Get the friendly name associated with the input class.
  40704. * @returns the input friendly name
  40705. */
  40706. getSimpleName(): string;
  40707. }
  40708. }
  40709. declare module BABYLON {
  40710. /**
  40711. * Defines the potential axis of a Joystick
  40712. */
  40713. export enum JoystickAxis {
  40714. /** X axis */
  40715. X = 0,
  40716. /** Y axis */
  40717. Y = 1,
  40718. /** Z axis */
  40719. Z = 2
  40720. }
  40721. /**
  40722. * Class used to define virtual joystick (used in touch mode)
  40723. */
  40724. export class VirtualJoystick {
  40725. /**
  40726. * Gets or sets a boolean indicating that left and right values must be inverted
  40727. */
  40728. reverseLeftRight: boolean;
  40729. /**
  40730. * Gets or sets a boolean indicating that up and down values must be inverted
  40731. */
  40732. reverseUpDown: boolean;
  40733. /**
  40734. * Gets the offset value for the position (ie. the change of the position value)
  40735. */
  40736. deltaPosition: Vector3;
  40737. /**
  40738. * Gets a boolean indicating if the virtual joystick was pressed
  40739. */
  40740. pressed: boolean;
  40741. /**
  40742. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40743. */
  40744. static Canvas: Nullable<HTMLCanvasElement>;
  40745. private static _globalJoystickIndex;
  40746. private static vjCanvasContext;
  40747. private static vjCanvasWidth;
  40748. private static vjCanvasHeight;
  40749. private static halfWidth;
  40750. private _action;
  40751. private _axisTargetedByLeftAndRight;
  40752. private _axisTargetedByUpAndDown;
  40753. private _joystickSensibility;
  40754. private _inversedSensibility;
  40755. private _joystickPointerID;
  40756. private _joystickColor;
  40757. private _joystickPointerPos;
  40758. private _joystickPreviousPointerPos;
  40759. private _joystickPointerStartPos;
  40760. private _deltaJoystickVector;
  40761. private _leftJoystick;
  40762. private _touches;
  40763. private _onPointerDownHandlerRef;
  40764. private _onPointerMoveHandlerRef;
  40765. private _onPointerUpHandlerRef;
  40766. private _onResize;
  40767. /**
  40768. * Creates a new virtual joystick
  40769. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40770. */
  40771. constructor(leftJoystick?: boolean);
  40772. /**
  40773. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40774. * @param newJoystickSensibility defines the new sensibility
  40775. */
  40776. setJoystickSensibility(newJoystickSensibility: number): void;
  40777. private _onPointerDown;
  40778. private _onPointerMove;
  40779. private _onPointerUp;
  40780. /**
  40781. * Change the color of the virtual joystick
  40782. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40783. */
  40784. setJoystickColor(newColor: string): void;
  40785. /**
  40786. * Defines a callback to call when the joystick is touched
  40787. * @param action defines the callback
  40788. */
  40789. setActionOnTouch(action: () => any): void;
  40790. /**
  40791. * Defines which axis you'd like to control for left & right
  40792. * @param axis defines the axis to use
  40793. */
  40794. setAxisForLeftRight(axis: JoystickAxis): void;
  40795. /**
  40796. * Defines which axis you'd like to control for up & down
  40797. * @param axis defines the axis to use
  40798. */
  40799. setAxisForUpDown(axis: JoystickAxis): void;
  40800. private _drawVirtualJoystick;
  40801. /**
  40802. * Release internal HTML canvas
  40803. */
  40804. releaseCanvas(): void;
  40805. }
  40806. }
  40807. declare module BABYLON {
  40808. interface FreeCameraInputsManager {
  40809. /**
  40810. * Add virtual joystick input support to the input manager.
  40811. * @returns the current input manager
  40812. */
  40813. addVirtualJoystick(): FreeCameraInputsManager;
  40814. }
  40815. /**
  40816. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40817. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40818. */
  40819. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40820. /**
  40821. * Defines the camera the input is attached to.
  40822. */
  40823. camera: FreeCamera;
  40824. private _leftjoystick;
  40825. private _rightjoystick;
  40826. /**
  40827. * Gets the left stick of the virtual joystick.
  40828. * @returns The virtual Joystick
  40829. */
  40830. getLeftJoystick(): VirtualJoystick;
  40831. /**
  40832. * Gets the right stick of the virtual joystick.
  40833. * @returns The virtual Joystick
  40834. */
  40835. getRightJoystick(): VirtualJoystick;
  40836. /**
  40837. * Update the current camera state depending on the inputs that have been used this frame.
  40838. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40839. */
  40840. checkInputs(): void;
  40841. /**
  40842. * Attach the input controls to a specific dom element to get the input from.
  40843. * @param element Defines the element the controls should be listened from
  40844. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40845. */
  40846. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40847. /**
  40848. * Detach the current controls from the specified dom element.
  40849. * @param element Defines the element to stop listening the inputs from
  40850. */
  40851. detachControl(element: Nullable<HTMLElement>): void;
  40852. /**
  40853. * Gets the class name of the current intput.
  40854. * @returns the class name
  40855. */
  40856. getClassName(): string;
  40857. /**
  40858. * Get the friendly name associated with the input class.
  40859. * @returns the input friendly name
  40860. */
  40861. getSimpleName(): string;
  40862. }
  40863. }
  40864. declare module BABYLON {
  40865. /**
  40866. * This represents a FPS type of camera controlled by touch.
  40867. * This is like a universal camera minus the Gamepad controls.
  40868. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40869. */
  40870. export class TouchCamera extends FreeCamera {
  40871. /**
  40872. * Defines the touch sensibility for rotation.
  40873. * The higher the faster.
  40874. */
  40875. get touchAngularSensibility(): number;
  40876. set touchAngularSensibility(value: number);
  40877. /**
  40878. * Defines the touch sensibility for move.
  40879. * The higher the faster.
  40880. */
  40881. get touchMoveSensibility(): number;
  40882. set touchMoveSensibility(value: number);
  40883. /**
  40884. * Instantiates a new touch camera.
  40885. * This represents a FPS type of camera controlled by touch.
  40886. * This is like a universal camera minus the Gamepad controls.
  40887. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40888. * @param name Define the name of the camera in the scene
  40889. * @param position Define the start position of the camera in the scene
  40890. * @param scene Define the scene the camera belongs to
  40891. */
  40892. constructor(name: string, position: Vector3, scene: Scene);
  40893. /**
  40894. * Gets the current object class name.
  40895. * @return the class name
  40896. */
  40897. getClassName(): string;
  40898. /** @hidden */
  40899. _setupInputs(): void;
  40900. }
  40901. }
  40902. declare module BABYLON {
  40903. /**
  40904. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40905. * being tilted forward or back and left or right.
  40906. */
  40907. export class DeviceOrientationCamera extends FreeCamera {
  40908. private _initialQuaternion;
  40909. private _quaternionCache;
  40910. private _tmpDragQuaternion;
  40911. private _disablePointerInputWhenUsingDeviceOrientation;
  40912. /**
  40913. * Creates a new device orientation camera
  40914. * @param name The name of the camera
  40915. * @param position The start position camera
  40916. * @param scene The scene the camera belongs to
  40917. */
  40918. constructor(name: string, position: Vector3, scene: Scene);
  40919. /**
  40920. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40921. */
  40922. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40923. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40924. private _dragFactor;
  40925. /**
  40926. * Enabled turning on the y axis when the orientation sensor is active
  40927. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40928. */
  40929. enableHorizontalDragging(dragFactor?: number): void;
  40930. /**
  40931. * Gets the current instance class name ("DeviceOrientationCamera").
  40932. * This helps avoiding instanceof at run time.
  40933. * @returns the class name
  40934. */
  40935. getClassName(): string;
  40936. /**
  40937. * @hidden
  40938. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40939. */
  40940. _checkInputs(): void;
  40941. /**
  40942. * Reset the camera to its default orientation on the specified axis only.
  40943. * @param axis The axis to reset
  40944. */
  40945. resetToCurrentRotation(axis?: Axis): void;
  40946. }
  40947. }
  40948. declare module BABYLON {
  40949. /**
  40950. * Defines supported buttons for XBox360 compatible gamepads
  40951. */
  40952. export enum Xbox360Button {
  40953. /** A */
  40954. A = 0,
  40955. /** B */
  40956. B = 1,
  40957. /** X */
  40958. X = 2,
  40959. /** Y */
  40960. Y = 3,
  40961. /** Start */
  40962. Start = 4,
  40963. /** Back */
  40964. Back = 5,
  40965. /** Left button */
  40966. LB = 6,
  40967. /** Right button */
  40968. RB = 7,
  40969. /** Left stick */
  40970. LeftStick = 8,
  40971. /** Right stick */
  40972. RightStick = 9
  40973. }
  40974. /** Defines values for XBox360 DPad */
  40975. export enum Xbox360Dpad {
  40976. /** Up */
  40977. Up = 0,
  40978. /** Down */
  40979. Down = 1,
  40980. /** Left */
  40981. Left = 2,
  40982. /** Right */
  40983. Right = 3
  40984. }
  40985. /**
  40986. * Defines a XBox360 gamepad
  40987. */
  40988. export class Xbox360Pad extends Gamepad {
  40989. private _leftTrigger;
  40990. private _rightTrigger;
  40991. private _onlefttriggerchanged;
  40992. private _onrighttriggerchanged;
  40993. private _onbuttondown;
  40994. private _onbuttonup;
  40995. private _ondpaddown;
  40996. private _ondpadup;
  40997. /** Observable raised when a button is pressed */
  40998. onButtonDownObservable: Observable<Xbox360Button>;
  40999. /** Observable raised when a button is released */
  41000. onButtonUpObservable: Observable<Xbox360Button>;
  41001. /** Observable raised when a pad is pressed */
  41002. onPadDownObservable: Observable<Xbox360Dpad>;
  41003. /** Observable raised when a pad is released */
  41004. onPadUpObservable: Observable<Xbox360Dpad>;
  41005. private _buttonA;
  41006. private _buttonB;
  41007. private _buttonX;
  41008. private _buttonY;
  41009. private _buttonBack;
  41010. private _buttonStart;
  41011. private _buttonLB;
  41012. private _buttonRB;
  41013. private _buttonLeftStick;
  41014. private _buttonRightStick;
  41015. private _dPadUp;
  41016. private _dPadDown;
  41017. private _dPadLeft;
  41018. private _dPadRight;
  41019. private _isXboxOnePad;
  41020. /**
  41021. * Creates a new XBox360 gamepad object
  41022. * @param id defines the id of this gamepad
  41023. * @param index defines its index
  41024. * @param gamepad defines the internal HTML gamepad object
  41025. * @param xboxOne defines if it is a XBox One gamepad
  41026. */
  41027. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41028. /**
  41029. * Defines the callback to call when left trigger is pressed
  41030. * @param callback defines the callback to use
  41031. */
  41032. onlefttriggerchanged(callback: (value: number) => void): void;
  41033. /**
  41034. * Defines the callback to call when right trigger is pressed
  41035. * @param callback defines the callback to use
  41036. */
  41037. onrighttriggerchanged(callback: (value: number) => void): void;
  41038. /**
  41039. * Gets the left trigger value
  41040. */
  41041. get leftTrigger(): number;
  41042. /**
  41043. * Sets the left trigger value
  41044. */
  41045. set leftTrigger(newValue: number);
  41046. /**
  41047. * Gets the right trigger value
  41048. */
  41049. get rightTrigger(): number;
  41050. /**
  41051. * Sets the right trigger value
  41052. */
  41053. set rightTrigger(newValue: number);
  41054. /**
  41055. * Defines the callback to call when a button is pressed
  41056. * @param callback defines the callback to use
  41057. */
  41058. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41059. /**
  41060. * Defines the callback to call when a button is released
  41061. * @param callback defines the callback to use
  41062. */
  41063. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41064. /**
  41065. * Defines the callback to call when a pad is pressed
  41066. * @param callback defines the callback to use
  41067. */
  41068. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41069. /**
  41070. * Defines the callback to call when a pad is released
  41071. * @param callback defines the callback to use
  41072. */
  41073. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41074. private _setButtonValue;
  41075. private _setDPadValue;
  41076. /**
  41077. * Gets the value of the `A` button
  41078. */
  41079. get buttonA(): number;
  41080. /**
  41081. * Sets the value of the `A` button
  41082. */
  41083. set buttonA(value: number);
  41084. /**
  41085. * Gets the value of the `B` button
  41086. */
  41087. get buttonB(): number;
  41088. /**
  41089. * Sets the value of the `B` button
  41090. */
  41091. set buttonB(value: number);
  41092. /**
  41093. * Gets the value of the `X` button
  41094. */
  41095. get buttonX(): number;
  41096. /**
  41097. * Sets the value of the `X` button
  41098. */
  41099. set buttonX(value: number);
  41100. /**
  41101. * Gets the value of the `Y` button
  41102. */
  41103. get buttonY(): number;
  41104. /**
  41105. * Sets the value of the `Y` button
  41106. */
  41107. set buttonY(value: number);
  41108. /**
  41109. * Gets the value of the `Start` button
  41110. */
  41111. get buttonStart(): number;
  41112. /**
  41113. * Sets the value of the `Start` button
  41114. */
  41115. set buttonStart(value: number);
  41116. /**
  41117. * Gets the value of the `Back` button
  41118. */
  41119. get buttonBack(): number;
  41120. /**
  41121. * Sets the value of the `Back` button
  41122. */
  41123. set buttonBack(value: number);
  41124. /**
  41125. * Gets the value of the `Left` button
  41126. */
  41127. get buttonLB(): number;
  41128. /**
  41129. * Sets the value of the `Left` button
  41130. */
  41131. set buttonLB(value: number);
  41132. /**
  41133. * Gets the value of the `Right` button
  41134. */
  41135. get buttonRB(): number;
  41136. /**
  41137. * Sets the value of the `Right` button
  41138. */
  41139. set buttonRB(value: number);
  41140. /**
  41141. * Gets the value of the Left joystick
  41142. */
  41143. get buttonLeftStick(): number;
  41144. /**
  41145. * Sets the value of the Left joystick
  41146. */
  41147. set buttonLeftStick(value: number);
  41148. /**
  41149. * Gets the value of the Right joystick
  41150. */
  41151. get buttonRightStick(): number;
  41152. /**
  41153. * Sets the value of the Right joystick
  41154. */
  41155. set buttonRightStick(value: number);
  41156. /**
  41157. * Gets the value of D-pad up
  41158. */
  41159. get dPadUp(): number;
  41160. /**
  41161. * Sets the value of D-pad up
  41162. */
  41163. set dPadUp(value: number);
  41164. /**
  41165. * Gets the value of D-pad down
  41166. */
  41167. get dPadDown(): number;
  41168. /**
  41169. * Sets the value of D-pad down
  41170. */
  41171. set dPadDown(value: number);
  41172. /**
  41173. * Gets the value of D-pad left
  41174. */
  41175. get dPadLeft(): number;
  41176. /**
  41177. * Sets the value of D-pad left
  41178. */
  41179. set dPadLeft(value: number);
  41180. /**
  41181. * Gets the value of D-pad right
  41182. */
  41183. get dPadRight(): number;
  41184. /**
  41185. * Sets the value of D-pad right
  41186. */
  41187. set dPadRight(value: number);
  41188. /**
  41189. * Force the gamepad to synchronize with device values
  41190. */
  41191. update(): void;
  41192. /**
  41193. * Disposes the gamepad
  41194. */
  41195. dispose(): void;
  41196. }
  41197. }
  41198. declare module BABYLON {
  41199. /**
  41200. * Defines supported buttons for DualShock compatible gamepads
  41201. */
  41202. export enum DualShockButton {
  41203. /** Cross */
  41204. Cross = 0,
  41205. /** Circle */
  41206. Circle = 1,
  41207. /** Square */
  41208. Square = 2,
  41209. /** Triangle */
  41210. Triangle = 3,
  41211. /** Options */
  41212. Options = 4,
  41213. /** Share */
  41214. Share = 5,
  41215. /** L1 */
  41216. L1 = 6,
  41217. /** R1 */
  41218. R1 = 7,
  41219. /** Left stick */
  41220. LeftStick = 8,
  41221. /** Right stick */
  41222. RightStick = 9
  41223. }
  41224. /** Defines values for DualShock DPad */
  41225. export enum DualShockDpad {
  41226. /** Up */
  41227. Up = 0,
  41228. /** Down */
  41229. Down = 1,
  41230. /** Left */
  41231. Left = 2,
  41232. /** Right */
  41233. Right = 3
  41234. }
  41235. /**
  41236. * Defines a DualShock gamepad
  41237. */
  41238. export class DualShockPad extends Gamepad {
  41239. private _leftTrigger;
  41240. private _rightTrigger;
  41241. private _onlefttriggerchanged;
  41242. private _onrighttriggerchanged;
  41243. private _onbuttondown;
  41244. private _onbuttonup;
  41245. private _ondpaddown;
  41246. private _ondpadup;
  41247. /** Observable raised when a button is pressed */
  41248. onButtonDownObservable: Observable<DualShockButton>;
  41249. /** Observable raised when a button is released */
  41250. onButtonUpObservable: Observable<DualShockButton>;
  41251. /** Observable raised when a pad is pressed */
  41252. onPadDownObservable: Observable<DualShockDpad>;
  41253. /** Observable raised when a pad is released */
  41254. onPadUpObservable: Observable<DualShockDpad>;
  41255. private _buttonCross;
  41256. private _buttonCircle;
  41257. private _buttonSquare;
  41258. private _buttonTriangle;
  41259. private _buttonShare;
  41260. private _buttonOptions;
  41261. private _buttonL1;
  41262. private _buttonR1;
  41263. private _buttonLeftStick;
  41264. private _buttonRightStick;
  41265. private _dPadUp;
  41266. private _dPadDown;
  41267. private _dPadLeft;
  41268. private _dPadRight;
  41269. /**
  41270. * Creates a new DualShock gamepad object
  41271. * @param id defines the id of this gamepad
  41272. * @param index defines its index
  41273. * @param gamepad defines the internal HTML gamepad object
  41274. */
  41275. constructor(id: string, index: number, gamepad: any);
  41276. /**
  41277. * Defines the callback to call when left trigger is pressed
  41278. * @param callback defines the callback to use
  41279. */
  41280. onlefttriggerchanged(callback: (value: number) => void): void;
  41281. /**
  41282. * Defines the callback to call when right trigger is pressed
  41283. * @param callback defines the callback to use
  41284. */
  41285. onrighttriggerchanged(callback: (value: number) => void): void;
  41286. /**
  41287. * Gets the left trigger value
  41288. */
  41289. get leftTrigger(): number;
  41290. /**
  41291. * Sets the left trigger value
  41292. */
  41293. set leftTrigger(newValue: number);
  41294. /**
  41295. * Gets the right trigger value
  41296. */
  41297. get rightTrigger(): number;
  41298. /**
  41299. * Sets the right trigger value
  41300. */
  41301. set rightTrigger(newValue: number);
  41302. /**
  41303. * Defines the callback to call when a button is pressed
  41304. * @param callback defines the callback to use
  41305. */
  41306. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41307. /**
  41308. * Defines the callback to call when a button is released
  41309. * @param callback defines the callback to use
  41310. */
  41311. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41312. /**
  41313. * Defines the callback to call when a pad is pressed
  41314. * @param callback defines the callback to use
  41315. */
  41316. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41317. /**
  41318. * Defines the callback to call when a pad is released
  41319. * @param callback defines the callback to use
  41320. */
  41321. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41322. private _setButtonValue;
  41323. private _setDPadValue;
  41324. /**
  41325. * Gets the value of the `Cross` button
  41326. */
  41327. get buttonCross(): number;
  41328. /**
  41329. * Sets the value of the `Cross` button
  41330. */
  41331. set buttonCross(value: number);
  41332. /**
  41333. * Gets the value of the `Circle` button
  41334. */
  41335. get buttonCircle(): number;
  41336. /**
  41337. * Sets the value of the `Circle` button
  41338. */
  41339. set buttonCircle(value: number);
  41340. /**
  41341. * Gets the value of the `Square` button
  41342. */
  41343. get buttonSquare(): number;
  41344. /**
  41345. * Sets the value of the `Square` button
  41346. */
  41347. set buttonSquare(value: number);
  41348. /**
  41349. * Gets the value of the `Triangle` button
  41350. */
  41351. get buttonTriangle(): number;
  41352. /**
  41353. * Sets the value of the `Triangle` button
  41354. */
  41355. set buttonTriangle(value: number);
  41356. /**
  41357. * Gets the value of the `Options` button
  41358. */
  41359. get buttonOptions(): number;
  41360. /**
  41361. * Sets the value of the `Options` button
  41362. */
  41363. set buttonOptions(value: number);
  41364. /**
  41365. * Gets the value of the `Share` button
  41366. */
  41367. get buttonShare(): number;
  41368. /**
  41369. * Sets the value of the `Share` button
  41370. */
  41371. set buttonShare(value: number);
  41372. /**
  41373. * Gets the value of the `L1` button
  41374. */
  41375. get buttonL1(): number;
  41376. /**
  41377. * Sets the value of the `L1` button
  41378. */
  41379. set buttonL1(value: number);
  41380. /**
  41381. * Gets the value of the `R1` button
  41382. */
  41383. get buttonR1(): number;
  41384. /**
  41385. * Sets the value of the `R1` button
  41386. */
  41387. set buttonR1(value: number);
  41388. /**
  41389. * Gets the value of the Left joystick
  41390. */
  41391. get buttonLeftStick(): number;
  41392. /**
  41393. * Sets the value of the Left joystick
  41394. */
  41395. set buttonLeftStick(value: number);
  41396. /**
  41397. * Gets the value of the Right joystick
  41398. */
  41399. get buttonRightStick(): number;
  41400. /**
  41401. * Sets the value of the Right joystick
  41402. */
  41403. set buttonRightStick(value: number);
  41404. /**
  41405. * Gets the value of D-pad up
  41406. */
  41407. get dPadUp(): number;
  41408. /**
  41409. * Sets the value of D-pad up
  41410. */
  41411. set dPadUp(value: number);
  41412. /**
  41413. * Gets the value of D-pad down
  41414. */
  41415. get dPadDown(): number;
  41416. /**
  41417. * Sets the value of D-pad down
  41418. */
  41419. set dPadDown(value: number);
  41420. /**
  41421. * Gets the value of D-pad left
  41422. */
  41423. get dPadLeft(): number;
  41424. /**
  41425. * Sets the value of D-pad left
  41426. */
  41427. set dPadLeft(value: number);
  41428. /**
  41429. * Gets the value of D-pad right
  41430. */
  41431. get dPadRight(): number;
  41432. /**
  41433. * Sets the value of D-pad right
  41434. */
  41435. set dPadRight(value: number);
  41436. /**
  41437. * Force the gamepad to synchronize with device values
  41438. */
  41439. update(): void;
  41440. /**
  41441. * Disposes the gamepad
  41442. */
  41443. dispose(): void;
  41444. }
  41445. }
  41446. declare module BABYLON {
  41447. /**
  41448. * Manager for handling gamepads
  41449. */
  41450. export class GamepadManager {
  41451. private _scene?;
  41452. private _babylonGamepads;
  41453. private _oneGamepadConnected;
  41454. /** @hidden */
  41455. _isMonitoring: boolean;
  41456. private _gamepadEventSupported;
  41457. private _gamepadSupport?;
  41458. /**
  41459. * observable to be triggered when the gamepad controller has been connected
  41460. */
  41461. onGamepadConnectedObservable: Observable<Gamepad>;
  41462. /**
  41463. * observable to be triggered when the gamepad controller has been disconnected
  41464. */
  41465. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41466. private _onGamepadConnectedEvent;
  41467. private _onGamepadDisconnectedEvent;
  41468. /**
  41469. * Initializes the gamepad manager
  41470. * @param _scene BabylonJS scene
  41471. */
  41472. constructor(_scene?: Scene | undefined);
  41473. /**
  41474. * The gamepads in the game pad manager
  41475. */
  41476. get gamepads(): Gamepad[];
  41477. /**
  41478. * Get the gamepad controllers based on type
  41479. * @param type The type of gamepad controller
  41480. * @returns Nullable gamepad
  41481. */
  41482. getGamepadByType(type?: number): Nullable<Gamepad>;
  41483. /**
  41484. * Disposes the gamepad manager
  41485. */
  41486. dispose(): void;
  41487. private _addNewGamepad;
  41488. private _startMonitoringGamepads;
  41489. private _stopMonitoringGamepads;
  41490. /** @hidden */
  41491. _checkGamepadsStatus(): void;
  41492. private _updateGamepadObjects;
  41493. }
  41494. }
  41495. declare module BABYLON {
  41496. interface Scene {
  41497. /** @hidden */
  41498. _gamepadManager: Nullable<GamepadManager>;
  41499. /**
  41500. * Gets the gamepad manager associated with the scene
  41501. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41502. */
  41503. gamepadManager: GamepadManager;
  41504. }
  41505. /**
  41506. * Interface representing a free camera inputs manager
  41507. */
  41508. interface FreeCameraInputsManager {
  41509. /**
  41510. * Adds gamepad input support to the FreeCameraInputsManager.
  41511. * @returns the FreeCameraInputsManager
  41512. */
  41513. addGamepad(): FreeCameraInputsManager;
  41514. }
  41515. /**
  41516. * Interface representing an arc rotate camera inputs manager
  41517. */
  41518. interface ArcRotateCameraInputsManager {
  41519. /**
  41520. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41521. * @returns the camera inputs manager
  41522. */
  41523. addGamepad(): ArcRotateCameraInputsManager;
  41524. }
  41525. /**
  41526. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41527. */
  41528. export class GamepadSystemSceneComponent implements ISceneComponent {
  41529. /**
  41530. * The component name helpfull to identify the component in the list of scene components.
  41531. */
  41532. readonly name: string;
  41533. /**
  41534. * The scene the component belongs to.
  41535. */
  41536. scene: Scene;
  41537. /**
  41538. * Creates a new instance of the component for the given scene
  41539. * @param scene Defines the scene to register the component in
  41540. */
  41541. constructor(scene: Scene);
  41542. /**
  41543. * Registers the component in a given scene
  41544. */
  41545. register(): void;
  41546. /**
  41547. * Rebuilds the elements related to this component in case of
  41548. * context lost for instance.
  41549. */
  41550. rebuild(): void;
  41551. /**
  41552. * Disposes the component and the associated ressources
  41553. */
  41554. dispose(): void;
  41555. private _beforeCameraUpdate;
  41556. }
  41557. }
  41558. declare module BABYLON {
  41559. /**
  41560. * 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,
  41561. * which still works and will still be found in many Playgrounds.
  41562. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41563. */
  41564. export class UniversalCamera extends TouchCamera {
  41565. /**
  41566. * Defines the gamepad rotation sensiblity.
  41567. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41568. */
  41569. get gamepadAngularSensibility(): number;
  41570. set gamepadAngularSensibility(value: number);
  41571. /**
  41572. * Defines the gamepad move sensiblity.
  41573. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41574. */
  41575. get gamepadMoveSensibility(): number;
  41576. set gamepadMoveSensibility(value: number);
  41577. /**
  41578. * 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,
  41579. * which still works and will still be found in many Playgrounds.
  41580. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41581. * @param name Define the name of the camera in the scene
  41582. * @param position Define the start position of the camera in the scene
  41583. * @param scene Define the scene the camera belongs to
  41584. */
  41585. constructor(name: string, position: Vector3, scene: Scene);
  41586. /**
  41587. * Gets the current object class name.
  41588. * @return the class name
  41589. */
  41590. getClassName(): string;
  41591. }
  41592. }
  41593. declare module BABYLON {
  41594. /**
  41595. * This represents a FPS type of camera. This is only here for back compat purpose.
  41596. * Please use the UniversalCamera instead as both are identical.
  41597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41598. */
  41599. export class GamepadCamera extends UniversalCamera {
  41600. /**
  41601. * Instantiates a new Gamepad Camera
  41602. * This represents a FPS type of camera. This is only here for back compat purpose.
  41603. * Please use the UniversalCamera instead as both are identical.
  41604. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41605. * @param name Define the name of the camera in the scene
  41606. * @param position Define the start position of the camera in the scene
  41607. * @param scene Define the scene the camera belongs to
  41608. */
  41609. constructor(name: string, position: Vector3, scene: Scene);
  41610. /**
  41611. * Gets the current object class name.
  41612. * @return the class name
  41613. */
  41614. getClassName(): string;
  41615. }
  41616. }
  41617. declare module BABYLON {
  41618. /** @hidden */
  41619. export var passPixelShader: {
  41620. name: string;
  41621. shader: string;
  41622. };
  41623. }
  41624. declare module BABYLON {
  41625. /** @hidden */
  41626. export var passCubePixelShader: {
  41627. name: string;
  41628. shader: string;
  41629. };
  41630. }
  41631. declare module BABYLON {
  41632. /**
  41633. * PassPostProcess which produces an output the same as it's input
  41634. */
  41635. export class PassPostProcess extends PostProcess {
  41636. /**
  41637. * Creates the PassPostProcess
  41638. * @param name The name of the effect.
  41639. * @param options The required width/height ratio to downsize to before computing the render pass.
  41640. * @param camera The camera to apply the render pass to.
  41641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41642. * @param engine The engine which the post process will be applied. (default: current engine)
  41643. * @param reusable If the post process can be reused on the same frame. (default: false)
  41644. * @param textureType The type of texture to be used when performing the post processing.
  41645. * @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)
  41646. */
  41647. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41648. }
  41649. /**
  41650. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41651. */
  41652. export class PassCubePostProcess extends PostProcess {
  41653. private _face;
  41654. /**
  41655. * Gets or sets the cube face to display.
  41656. * * 0 is +X
  41657. * * 1 is -X
  41658. * * 2 is +Y
  41659. * * 3 is -Y
  41660. * * 4 is +Z
  41661. * * 5 is -Z
  41662. */
  41663. get face(): number;
  41664. set face(value: number);
  41665. /**
  41666. * Creates the PassCubePostProcess
  41667. * @param name The name of the effect.
  41668. * @param options The required width/height ratio to downsize to before computing the render pass.
  41669. * @param camera The camera to apply the render pass to.
  41670. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41671. * @param engine The engine which the post process will be applied. (default: current engine)
  41672. * @param reusable If the post process can be reused on the same frame. (default: false)
  41673. * @param textureType The type of texture to be used when performing the post processing.
  41674. * @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)
  41675. */
  41676. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41677. }
  41678. }
  41679. declare module BABYLON {
  41680. /** @hidden */
  41681. export var anaglyphPixelShader: {
  41682. name: string;
  41683. shader: string;
  41684. };
  41685. }
  41686. declare module BABYLON {
  41687. /**
  41688. * Postprocess used to generate anaglyphic rendering
  41689. */
  41690. export class AnaglyphPostProcess extends PostProcess {
  41691. private _passedProcess;
  41692. /**
  41693. * Creates a new AnaglyphPostProcess
  41694. * @param name defines postprocess name
  41695. * @param options defines creation options or target ratio scale
  41696. * @param rigCameras defines cameras using this postprocess
  41697. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41698. * @param engine defines hosting engine
  41699. * @param reusable defines if the postprocess will be reused multiple times per frame
  41700. */
  41701. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41702. }
  41703. }
  41704. declare module BABYLON {
  41705. /**
  41706. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41707. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41708. */
  41709. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41710. /**
  41711. * Creates a new AnaglyphArcRotateCamera
  41712. * @param name defines camera name
  41713. * @param alpha defines alpha angle (in radians)
  41714. * @param beta defines beta angle (in radians)
  41715. * @param radius defines radius
  41716. * @param target defines camera target
  41717. * @param interaxialDistance defines distance between each color axis
  41718. * @param scene defines the hosting scene
  41719. */
  41720. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41721. /**
  41722. * Gets camera class name
  41723. * @returns AnaglyphArcRotateCamera
  41724. */
  41725. getClassName(): string;
  41726. }
  41727. }
  41728. declare module BABYLON {
  41729. /**
  41730. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41731. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41732. */
  41733. export class AnaglyphFreeCamera extends FreeCamera {
  41734. /**
  41735. * Creates a new AnaglyphFreeCamera
  41736. * @param name defines camera name
  41737. * @param position defines initial position
  41738. * @param interaxialDistance defines distance between each color axis
  41739. * @param scene defines the hosting scene
  41740. */
  41741. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41742. /**
  41743. * Gets camera class name
  41744. * @returns AnaglyphFreeCamera
  41745. */
  41746. getClassName(): string;
  41747. }
  41748. }
  41749. declare module BABYLON {
  41750. /**
  41751. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41752. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41753. */
  41754. export class AnaglyphGamepadCamera extends GamepadCamera {
  41755. /**
  41756. * Creates a new AnaglyphGamepadCamera
  41757. * @param name defines camera name
  41758. * @param position defines initial position
  41759. * @param interaxialDistance defines distance between each color axis
  41760. * @param scene defines the hosting scene
  41761. */
  41762. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41763. /**
  41764. * Gets camera class name
  41765. * @returns AnaglyphGamepadCamera
  41766. */
  41767. getClassName(): string;
  41768. }
  41769. }
  41770. declare module BABYLON {
  41771. /**
  41772. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41773. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41774. */
  41775. export class AnaglyphUniversalCamera extends UniversalCamera {
  41776. /**
  41777. * Creates a new AnaglyphUniversalCamera
  41778. * @param name defines camera name
  41779. * @param position defines initial position
  41780. * @param interaxialDistance defines distance between each color axis
  41781. * @param scene defines the hosting scene
  41782. */
  41783. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41784. /**
  41785. * Gets camera class name
  41786. * @returns AnaglyphUniversalCamera
  41787. */
  41788. getClassName(): string;
  41789. }
  41790. }
  41791. declare module BABYLON {
  41792. /** @hidden */
  41793. export var stereoscopicInterlacePixelShader: {
  41794. name: string;
  41795. shader: string;
  41796. };
  41797. }
  41798. declare module BABYLON {
  41799. /**
  41800. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41801. */
  41802. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41803. private _stepSize;
  41804. private _passedProcess;
  41805. /**
  41806. * Initializes a StereoscopicInterlacePostProcessI
  41807. * @param name The name of the effect.
  41808. * @param rigCameras The rig cameras to be appled to the post process
  41809. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41810. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41811. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41812. * @param engine The engine which the post process will be applied. (default: current engine)
  41813. * @param reusable If the post process can be reused on the same frame. (default: false)
  41814. */
  41815. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41816. }
  41817. /**
  41818. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41819. */
  41820. export class StereoscopicInterlacePostProcess extends PostProcess {
  41821. private _stepSize;
  41822. private _passedProcess;
  41823. /**
  41824. * Initializes a StereoscopicInterlacePostProcess
  41825. * @param name The name of the effect.
  41826. * @param rigCameras The rig cameras to be appled to the post process
  41827. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41828. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41829. * @param engine The engine which the post process will be applied. (default: current engine)
  41830. * @param reusable If the post process can be reused on the same frame. (default: false)
  41831. */
  41832. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41833. }
  41834. }
  41835. declare module BABYLON {
  41836. /**
  41837. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41838. * @see http://doc.babylonjs.com/features/cameras
  41839. */
  41840. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41841. /**
  41842. * Creates a new StereoscopicArcRotateCamera
  41843. * @param name defines camera name
  41844. * @param alpha defines alpha angle (in radians)
  41845. * @param beta defines beta angle (in radians)
  41846. * @param radius defines radius
  41847. * @param target defines camera target
  41848. * @param interaxialDistance defines distance between each color axis
  41849. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41850. * @param scene defines the hosting scene
  41851. */
  41852. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41853. /**
  41854. * Gets camera class name
  41855. * @returns StereoscopicArcRotateCamera
  41856. */
  41857. getClassName(): string;
  41858. }
  41859. }
  41860. declare module BABYLON {
  41861. /**
  41862. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41863. * @see http://doc.babylonjs.com/features/cameras
  41864. */
  41865. export class StereoscopicFreeCamera extends FreeCamera {
  41866. /**
  41867. * Creates a new StereoscopicFreeCamera
  41868. * @param name defines camera name
  41869. * @param position defines initial position
  41870. * @param interaxialDistance defines distance between each color axis
  41871. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41872. * @param scene defines the hosting scene
  41873. */
  41874. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41875. /**
  41876. * Gets camera class name
  41877. * @returns StereoscopicFreeCamera
  41878. */
  41879. getClassName(): string;
  41880. }
  41881. }
  41882. declare module BABYLON {
  41883. /**
  41884. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41885. * @see http://doc.babylonjs.com/features/cameras
  41886. */
  41887. export class StereoscopicGamepadCamera extends GamepadCamera {
  41888. /**
  41889. * Creates a new StereoscopicGamepadCamera
  41890. * @param name defines camera name
  41891. * @param position defines initial position
  41892. * @param interaxialDistance defines distance between each color axis
  41893. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41894. * @param scene defines the hosting scene
  41895. */
  41896. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41897. /**
  41898. * Gets camera class name
  41899. * @returns StereoscopicGamepadCamera
  41900. */
  41901. getClassName(): string;
  41902. }
  41903. }
  41904. declare module BABYLON {
  41905. /**
  41906. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41907. * @see http://doc.babylonjs.com/features/cameras
  41908. */
  41909. export class StereoscopicUniversalCamera extends UniversalCamera {
  41910. /**
  41911. * Creates a new StereoscopicUniversalCamera
  41912. * @param name defines camera name
  41913. * @param position defines initial position
  41914. * @param interaxialDistance defines distance between each color axis
  41915. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41916. * @param scene defines the hosting scene
  41917. */
  41918. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41919. /**
  41920. * Gets camera class name
  41921. * @returns StereoscopicUniversalCamera
  41922. */
  41923. getClassName(): string;
  41924. }
  41925. }
  41926. declare module BABYLON {
  41927. /**
  41928. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41929. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41930. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41931. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41932. */
  41933. export class VirtualJoysticksCamera extends FreeCamera {
  41934. /**
  41935. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41936. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41937. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41938. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41939. * @param name Define the name of the camera in the scene
  41940. * @param position Define the start position of the camera in the scene
  41941. * @param scene Define the scene the camera belongs to
  41942. */
  41943. constructor(name: string, position: Vector3, scene: Scene);
  41944. /**
  41945. * Gets the current object class name.
  41946. * @return the class name
  41947. */
  41948. getClassName(): string;
  41949. }
  41950. }
  41951. declare module BABYLON {
  41952. /**
  41953. * This represents all the required metrics to create a VR camera.
  41954. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41955. */
  41956. export class VRCameraMetrics {
  41957. /**
  41958. * Define the horizontal resolution off the screen.
  41959. */
  41960. hResolution: number;
  41961. /**
  41962. * Define the vertical resolution off the screen.
  41963. */
  41964. vResolution: number;
  41965. /**
  41966. * Define the horizontal screen size.
  41967. */
  41968. hScreenSize: number;
  41969. /**
  41970. * Define the vertical screen size.
  41971. */
  41972. vScreenSize: number;
  41973. /**
  41974. * Define the vertical screen center position.
  41975. */
  41976. vScreenCenter: number;
  41977. /**
  41978. * Define the distance of the eyes to the screen.
  41979. */
  41980. eyeToScreenDistance: number;
  41981. /**
  41982. * Define the distance between both lenses
  41983. */
  41984. lensSeparationDistance: number;
  41985. /**
  41986. * Define the distance between both viewer's eyes.
  41987. */
  41988. interpupillaryDistance: number;
  41989. /**
  41990. * Define the distortion factor of the VR postprocess.
  41991. * Please, touch with care.
  41992. */
  41993. distortionK: number[];
  41994. /**
  41995. * Define the chromatic aberration correction factors for the VR post process.
  41996. */
  41997. chromaAbCorrection: number[];
  41998. /**
  41999. * Define the scale factor of the post process.
  42000. * The smaller the better but the slower.
  42001. */
  42002. postProcessScaleFactor: number;
  42003. /**
  42004. * Define an offset for the lens center.
  42005. */
  42006. lensCenterOffset: number;
  42007. /**
  42008. * Define if the current vr camera should compensate the distortion of the lense or not.
  42009. */
  42010. compensateDistortion: boolean;
  42011. /**
  42012. * Defines if multiview should be enabled when rendering (Default: false)
  42013. */
  42014. multiviewEnabled: boolean;
  42015. /**
  42016. * Gets the rendering aspect ratio based on the provided resolutions.
  42017. */
  42018. get aspectRatio(): number;
  42019. /**
  42020. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42021. */
  42022. get aspectRatioFov(): number;
  42023. /**
  42024. * @hidden
  42025. */
  42026. get leftHMatrix(): Matrix;
  42027. /**
  42028. * @hidden
  42029. */
  42030. get rightHMatrix(): Matrix;
  42031. /**
  42032. * @hidden
  42033. */
  42034. get leftPreViewMatrix(): Matrix;
  42035. /**
  42036. * @hidden
  42037. */
  42038. get rightPreViewMatrix(): Matrix;
  42039. /**
  42040. * Get the default VRMetrics based on the most generic setup.
  42041. * @returns the default vr metrics
  42042. */
  42043. static GetDefault(): VRCameraMetrics;
  42044. }
  42045. }
  42046. declare module BABYLON {
  42047. /** @hidden */
  42048. export var vrDistortionCorrectionPixelShader: {
  42049. name: string;
  42050. shader: string;
  42051. };
  42052. }
  42053. declare module BABYLON {
  42054. /**
  42055. * VRDistortionCorrectionPostProcess used for mobile VR
  42056. */
  42057. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42058. private _isRightEye;
  42059. private _distortionFactors;
  42060. private _postProcessScaleFactor;
  42061. private _lensCenterOffset;
  42062. private _scaleIn;
  42063. private _scaleFactor;
  42064. private _lensCenter;
  42065. /**
  42066. * Initializes the VRDistortionCorrectionPostProcess
  42067. * @param name The name of the effect.
  42068. * @param camera The camera to apply the render pass to.
  42069. * @param isRightEye If this is for the right eye distortion
  42070. * @param vrMetrics All the required metrics for the VR camera
  42071. */
  42072. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42073. }
  42074. }
  42075. declare module BABYLON {
  42076. /**
  42077. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42078. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42079. */
  42080. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42081. /**
  42082. * Creates a new VRDeviceOrientationArcRotateCamera
  42083. * @param name defines camera name
  42084. * @param alpha defines the camera rotation along the logitudinal axis
  42085. * @param beta defines the camera rotation along the latitudinal axis
  42086. * @param radius defines the camera distance from its target
  42087. * @param target defines the camera target
  42088. * @param scene defines the scene the camera belongs to
  42089. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42090. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42091. */
  42092. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42093. /**
  42094. * Gets camera class name
  42095. * @returns VRDeviceOrientationArcRotateCamera
  42096. */
  42097. getClassName(): string;
  42098. }
  42099. }
  42100. declare module BABYLON {
  42101. /**
  42102. * Camera used to simulate VR rendering (based on FreeCamera)
  42103. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42104. */
  42105. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42106. /**
  42107. * Creates a new VRDeviceOrientationFreeCamera
  42108. * @param name defines camera name
  42109. * @param position defines the start position of the camera
  42110. * @param scene defines the scene the camera belongs to
  42111. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42112. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42113. */
  42114. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42115. /**
  42116. * Gets camera class name
  42117. * @returns VRDeviceOrientationFreeCamera
  42118. */
  42119. getClassName(): string;
  42120. }
  42121. }
  42122. declare module BABYLON {
  42123. /**
  42124. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42125. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42126. */
  42127. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42128. /**
  42129. * Creates a new VRDeviceOrientationGamepadCamera
  42130. * @param name defines camera name
  42131. * @param position defines the start position of the camera
  42132. * @param scene defines the scene the camera belongs to
  42133. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42134. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42135. */
  42136. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42137. /**
  42138. * Gets camera class name
  42139. * @returns VRDeviceOrientationGamepadCamera
  42140. */
  42141. getClassName(): string;
  42142. }
  42143. }
  42144. declare module BABYLON {
  42145. /** @hidden */
  42146. export var imageProcessingPixelShader: {
  42147. name: string;
  42148. shader: string;
  42149. };
  42150. }
  42151. declare module BABYLON {
  42152. /**
  42153. * ImageProcessingPostProcess
  42154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42155. */
  42156. export class ImageProcessingPostProcess extends PostProcess {
  42157. /**
  42158. * Default configuration related to image processing available in the PBR Material.
  42159. */
  42160. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42161. /**
  42162. * Gets the image processing configuration used either in this material.
  42163. */
  42164. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42165. /**
  42166. * Sets the Default image processing configuration used either in the this material.
  42167. *
  42168. * If sets to null, the scene one is in use.
  42169. */
  42170. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42171. /**
  42172. * Keep track of the image processing observer to allow dispose and replace.
  42173. */
  42174. private _imageProcessingObserver;
  42175. /**
  42176. * Attaches a new image processing configuration to the PBR Material.
  42177. * @param configuration
  42178. */
  42179. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42180. /**
  42181. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42182. */
  42183. get colorCurves(): Nullable<ColorCurves>;
  42184. /**
  42185. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42186. */
  42187. set colorCurves(value: Nullable<ColorCurves>);
  42188. /**
  42189. * Gets wether the color curves effect is enabled.
  42190. */
  42191. get colorCurvesEnabled(): boolean;
  42192. /**
  42193. * Sets wether the color curves effect is enabled.
  42194. */
  42195. set colorCurvesEnabled(value: boolean);
  42196. /**
  42197. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42198. */
  42199. get colorGradingTexture(): Nullable<BaseTexture>;
  42200. /**
  42201. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42202. */
  42203. set colorGradingTexture(value: Nullable<BaseTexture>);
  42204. /**
  42205. * Gets wether the color grading effect is enabled.
  42206. */
  42207. get colorGradingEnabled(): boolean;
  42208. /**
  42209. * Gets wether the color grading effect is enabled.
  42210. */
  42211. set colorGradingEnabled(value: boolean);
  42212. /**
  42213. * Gets exposure used in the effect.
  42214. */
  42215. get exposure(): number;
  42216. /**
  42217. * Sets exposure used in the effect.
  42218. */
  42219. set exposure(value: number);
  42220. /**
  42221. * Gets wether tonemapping is enabled or not.
  42222. */
  42223. get toneMappingEnabled(): boolean;
  42224. /**
  42225. * Sets wether tonemapping is enabled or not
  42226. */
  42227. set toneMappingEnabled(value: boolean);
  42228. /**
  42229. * Gets the type of tone mapping effect.
  42230. */
  42231. get toneMappingType(): number;
  42232. /**
  42233. * Sets the type of tone mapping effect.
  42234. */
  42235. set toneMappingType(value: number);
  42236. /**
  42237. * Gets contrast used in the effect.
  42238. */
  42239. get contrast(): number;
  42240. /**
  42241. * Sets contrast used in the effect.
  42242. */
  42243. set contrast(value: number);
  42244. /**
  42245. * Gets Vignette stretch size.
  42246. */
  42247. get vignetteStretch(): number;
  42248. /**
  42249. * Sets Vignette stretch size.
  42250. */
  42251. set vignetteStretch(value: number);
  42252. /**
  42253. * Gets Vignette centre X Offset.
  42254. */
  42255. get vignetteCentreX(): number;
  42256. /**
  42257. * Sets Vignette centre X Offset.
  42258. */
  42259. set vignetteCentreX(value: number);
  42260. /**
  42261. * Gets Vignette centre Y Offset.
  42262. */
  42263. get vignetteCentreY(): number;
  42264. /**
  42265. * Sets Vignette centre Y Offset.
  42266. */
  42267. set vignetteCentreY(value: number);
  42268. /**
  42269. * Gets Vignette weight or intensity of the vignette effect.
  42270. */
  42271. get vignetteWeight(): number;
  42272. /**
  42273. * Sets Vignette weight or intensity of the vignette effect.
  42274. */
  42275. set vignetteWeight(value: number);
  42276. /**
  42277. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42278. * if vignetteEnabled is set to true.
  42279. */
  42280. get vignetteColor(): Color4;
  42281. /**
  42282. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42283. * if vignetteEnabled is set to true.
  42284. */
  42285. set vignetteColor(value: Color4);
  42286. /**
  42287. * Gets Camera field of view used by the Vignette effect.
  42288. */
  42289. get vignetteCameraFov(): number;
  42290. /**
  42291. * Sets Camera field of view used by the Vignette effect.
  42292. */
  42293. set vignetteCameraFov(value: number);
  42294. /**
  42295. * Gets the vignette blend mode allowing different kind of effect.
  42296. */
  42297. get vignetteBlendMode(): number;
  42298. /**
  42299. * Sets the vignette blend mode allowing different kind of effect.
  42300. */
  42301. set vignetteBlendMode(value: number);
  42302. /**
  42303. * Gets wether the vignette effect is enabled.
  42304. */
  42305. get vignetteEnabled(): boolean;
  42306. /**
  42307. * Sets wether the vignette effect is enabled.
  42308. */
  42309. set vignetteEnabled(value: boolean);
  42310. private _fromLinearSpace;
  42311. /**
  42312. * Gets wether the input of the processing is in Gamma or Linear Space.
  42313. */
  42314. get fromLinearSpace(): boolean;
  42315. /**
  42316. * Sets wether the input of the processing is in Gamma or Linear Space.
  42317. */
  42318. set fromLinearSpace(value: boolean);
  42319. /**
  42320. * Defines cache preventing GC.
  42321. */
  42322. private _defines;
  42323. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42324. /**
  42325. * "ImageProcessingPostProcess"
  42326. * @returns "ImageProcessingPostProcess"
  42327. */
  42328. getClassName(): string;
  42329. protected _updateParameters(): void;
  42330. dispose(camera?: Camera): void;
  42331. }
  42332. }
  42333. declare module BABYLON {
  42334. /**
  42335. * Class containing static functions to help procedurally build meshes
  42336. */
  42337. export class GroundBuilder {
  42338. /**
  42339. * Creates a ground mesh
  42340. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42341. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42343. * @param name defines the name of the mesh
  42344. * @param options defines the options used to create the mesh
  42345. * @param scene defines the hosting scene
  42346. * @returns the ground mesh
  42347. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42348. */
  42349. static CreateGround(name: string, options: {
  42350. width?: number;
  42351. height?: number;
  42352. subdivisions?: number;
  42353. subdivisionsX?: number;
  42354. subdivisionsY?: number;
  42355. updatable?: boolean;
  42356. }, scene: any): Mesh;
  42357. /**
  42358. * Creates a tiled ground mesh
  42359. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42360. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42361. * * 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
  42362. * * 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
  42363. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42364. * @param name defines the name of the mesh
  42365. * @param options defines the options used to create the mesh
  42366. * @param scene defines the hosting scene
  42367. * @returns the tiled ground mesh
  42368. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42369. */
  42370. static CreateTiledGround(name: string, options: {
  42371. xmin: number;
  42372. zmin: number;
  42373. xmax: number;
  42374. zmax: number;
  42375. subdivisions?: {
  42376. w: number;
  42377. h: number;
  42378. };
  42379. precision?: {
  42380. w: number;
  42381. h: number;
  42382. };
  42383. updatable?: boolean;
  42384. }, scene?: Nullable<Scene>): Mesh;
  42385. /**
  42386. * Creates a ground mesh from a height map
  42387. * * The parameter `url` sets the URL of the height map image resource.
  42388. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42389. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42390. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42391. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42392. * * 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.
  42393. * * 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).
  42394. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42396. * @param name defines the name of the mesh
  42397. * @param url defines the url to the height map
  42398. * @param options defines the options used to create the mesh
  42399. * @param scene defines the hosting scene
  42400. * @returns the ground mesh
  42401. * @see https://doc.babylonjs.com/babylon101/height_map
  42402. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42403. */
  42404. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42405. width?: number;
  42406. height?: number;
  42407. subdivisions?: number;
  42408. minHeight?: number;
  42409. maxHeight?: number;
  42410. colorFilter?: Color3;
  42411. alphaFilter?: number;
  42412. updatable?: boolean;
  42413. onReady?: (mesh: GroundMesh) => void;
  42414. }, scene?: Nullable<Scene>): GroundMesh;
  42415. }
  42416. }
  42417. declare module BABYLON {
  42418. /**
  42419. * Class containing static functions to help procedurally build meshes
  42420. */
  42421. export class TorusBuilder {
  42422. /**
  42423. * Creates a torus mesh
  42424. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42425. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42426. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42428. * * 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
  42429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42430. * @param name defines the name of the mesh
  42431. * @param options defines the options used to create the mesh
  42432. * @param scene defines the hosting scene
  42433. * @returns the torus mesh
  42434. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42435. */
  42436. static CreateTorus(name: string, options: {
  42437. diameter?: number;
  42438. thickness?: number;
  42439. tessellation?: number;
  42440. updatable?: boolean;
  42441. sideOrientation?: number;
  42442. frontUVs?: Vector4;
  42443. backUVs?: Vector4;
  42444. }, scene: any): Mesh;
  42445. }
  42446. }
  42447. declare module BABYLON {
  42448. /**
  42449. * Class containing static functions to help procedurally build meshes
  42450. */
  42451. export class CylinderBuilder {
  42452. /**
  42453. * Creates a cylinder or a cone mesh
  42454. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42455. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42456. * * 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.
  42457. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42458. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42459. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42460. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42461. * * 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).
  42462. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42463. * * 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).
  42464. * * 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
  42465. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42466. * * 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
  42467. * * 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.
  42468. * * If `enclose` is false, a ring surface is one element.
  42469. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42470. * * 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
  42471. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42472. * * 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
  42473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42474. * @param name defines the name of the mesh
  42475. * @param options defines the options used to create the mesh
  42476. * @param scene defines the hosting scene
  42477. * @returns the cylinder mesh
  42478. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42479. */
  42480. static CreateCylinder(name: string, options: {
  42481. height?: number;
  42482. diameterTop?: number;
  42483. diameterBottom?: number;
  42484. diameter?: number;
  42485. tessellation?: number;
  42486. subdivisions?: number;
  42487. arc?: number;
  42488. faceColors?: Color4[];
  42489. faceUV?: Vector4[];
  42490. updatable?: boolean;
  42491. hasRings?: boolean;
  42492. enclose?: boolean;
  42493. cap?: number;
  42494. sideOrientation?: number;
  42495. frontUVs?: Vector4;
  42496. backUVs?: Vector4;
  42497. }, scene: any): Mesh;
  42498. }
  42499. }
  42500. declare module BABYLON {
  42501. /**
  42502. * States of the webXR experience
  42503. */
  42504. export enum WebXRState {
  42505. /**
  42506. * Transitioning to being in XR mode
  42507. */
  42508. ENTERING_XR = 0,
  42509. /**
  42510. * Transitioning to non XR mode
  42511. */
  42512. EXITING_XR = 1,
  42513. /**
  42514. * In XR mode and presenting
  42515. */
  42516. IN_XR = 2,
  42517. /**
  42518. * Not entered XR mode
  42519. */
  42520. NOT_IN_XR = 3
  42521. }
  42522. /**
  42523. * Abstraction of the XR render target
  42524. */
  42525. export interface WebXRRenderTarget extends IDisposable {
  42526. /**
  42527. * xrpresent context of the canvas which can be used to display/mirror xr content
  42528. */
  42529. canvasContext: WebGLRenderingContext;
  42530. /**
  42531. * xr layer for the canvas
  42532. */
  42533. xrLayer: Nullable<XRWebGLLayer>;
  42534. /**
  42535. * Initializes the xr layer for the session
  42536. * @param xrSession xr session
  42537. * @returns a promise that will resolve once the XR Layer has been created
  42538. */
  42539. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42540. }
  42541. }
  42542. declare module BABYLON {
  42543. /**
  42544. * COnfiguration object for WebXR output canvas
  42545. */
  42546. export class WebXRManagedOutputCanvasOptions {
  42547. /**
  42548. * Options for this XR Layer output
  42549. */
  42550. canvasOptions?: XRWebGLLayerOptions;
  42551. /**
  42552. * CSS styling for a newly created canvas (if not provided)
  42553. */
  42554. newCanvasCssStyle?: string;
  42555. /**
  42556. * An optional canvas in case you wish to create it yourself and provide it here.
  42557. * If not provided, a new canvas will be created
  42558. */
  42559. canvasElement?: HTMLCanvasElement;
  42560. /**
  42561. * Get the default values of the configuration object
  42562. * @returns default values of this configuration object
  42563. */
  42564. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42565. }
  42566. /**
  42567. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42568. */
  42569. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42570. private _options;
  42571. private _engine;
  42572. private _canvas;
  42573. /**
  42574. * Rendering context of the canvas which can be used to display/mirror xr content
  42575. */
  42576. canvasContext: WebGLRenderingContext;
  42577. /**
  42578. * xr layer for the canvas
  42579. */
  42580. xrLayer: Nullable<XRWebGLLayer>;
  42581. /**
  42582. * Initializes the xr layer for the session
  42583. * @param xrSession xr session
  42584. * @returns a promise that will resolve once the XR Layer has been created
  42585. */
  42586. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42587. /**
  42588. * Initializes the canvas to be added/removed upon entering/exiting xr
  42589. * @param _xrSessionManager The XR Session manager
  42590. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42591. */
  42592. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42593. /**
  42594. * Disposes of the object
  42595. */
  42596. dispose(): void;
  42597. private _setManagedOutputCanvas;
  42598. private _addCanvas;
  42599. private _removeCanvas;
  42600. }
  42601. }
  42602. declare module BABYLON {
  42603. /**
  42604. * Manages an XRSession to work with Babylon's engine
  42605. * @see https://doc.babylonjs.com/how_to/webxr
  42606. */
  42607. export class WebXRSessionManager implements IDisposable {
  42608. /** The scene which the session should be created for */
  42609. scene: Scene;
  42610. /**
  42611. * Fires every time a new xrFrame arrives which can be used to update the camera
  42612. */
  42613. onXRFrameObservable: Observable<XRFrame>;
  42614. /**
  42615. * Fires when the xr session is ended either by the device or manually done
  42616. */
  42617. onXRSessionEnded: Observable<any>;
  42618. /**
  42619. * Fires when the xr session is ended either by the device or manually done
  42620. */
  42621. onXRSessionInit: Observable<XRSession>;
  42622. /**
  42623. * Fires when the reference space changed
  42624. */
  42625. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42626. /**
  42627. * Underlying xr session
  42628. */
  42629. session: XRSession;
  42630. /**
  42631. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42632. * or get the offset the player is currently at.
  42633. */
  42634. viewerReferenceSpace: XRReferenceSpace;
  42635. private _referenceSpace;
  42636. /**
  42637. * The current reference space used in this session. This reference space can constantly change!
  42638. * It is mainly used to offset the camera's position.
  42639. */
  42640. get referenceSpace(): XRReferenceSpace;
  42641. /**
  42642. * Set a new reference space and triggers the observable
  42643. */
  42644. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42645. /**
  42646. * The base reference space from which the session started. good if you want to reset your
  42647. * reference space
  42648. */
  42649. baseReferenceSpace: XRReferenceSpace;
  42650. /**
  42651. * Used just in case of a failure to initialize an immersive session.
  42652. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42653. */
  42654. defaultHeightCompensation: number;
  42655. /**
  42656. * Current XR frame
  42657. */
  42658. currentFrame: Nullable<XRFrame>;
  42659. /** WebXR timestamp updated every frame */
  42660. currentTimestamp: number;
  42661. private _xrNavigator;
  42662. private baseLayer;
  42663. private _rttProvider;
  42664. private _sessionEnded;
  42665. /**
  42666. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42667. * @param scene The scene which the session should be created for
  42668. */
  42669. constructor(
  42670. /** The scene which the session should be created for */
  42671. scene: Scene);
  42672. /**
  42673. * Initializes the manager
  42674. * After initialization enterXR can be called to start an XR session
  42675. * @returns Promise which resolves after it is initialized
  42676. */
  42677. initializeAsync(): Promise<void>;
  42678. /**
  42679. * Initializes an xr session
  42680. * @param xrSessionMode mode to initialize
  42681. * @param xrSessionInit defines optional and required values to pass to the session builder
  42682. * @returns a promise which will resolve once the session has been initialized
  42683. */
  42684. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42685. /**
  42686. * Sets the reference space on the xr session
  42687. * @param referenceSpaceType space to set
  42688. * @returns a promise that will resolve once the reference space has been set
  42689. */
  42690. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42691. /**
  42692. * Resets the reference space to the one started the session
  42693. */
  42694. resetReferenceSpace(): void;
  42695. /**
  42696. * Updates the render state of the session
  42697. * @param state state to set
  42698. * @returns a promise that resolves once the render state has been updated
  42699. */
  42700. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42701. /**
  42702. * Starts rendering to the xr layer
  42703. */
  42704. runXRRenderLoop(): void;
  42705. /**
  42706. * Gets the correct render target texture to be rendered this frame for this eye
  42707. * @param eye the eye for which to get the render target
  42708. * @returns the render target for the specified eye
  42709. */
  42710. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42711. /**
  42712. * Stops the xrSession and restores the renderloop
  42713. * @returns Promise which resolves after it exits XR
  42714. */
  42715. exitXRAsync(): Promise<void>;
  42716. /**
  42717. * Checks if a session would be supported for the creation options specified
  42718. * @param sessionMode session mode to check if supported eg. immersive-vr
  42719. * @returns A Promise that resolves to true if supported and false if not
  42720. */
  42721. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42722. /**
  42723. * Creates a WebXRRenderTarget object for the XR session
  42724. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42725. * @param options optional options to provide when creating a new render target
  42726. * @returns a WebXR render target to which the session can render
  42727. */
  42728. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42729. /**
  42730. * @hidden
  42731. * Converts the render layer of xrSession to a render target
  42732. * @param session session to create render target for
  42733. * @param scene scene the new render target should be created for
  42734. * @param baseLayer the webgl layer to create the render target for
  42735. */
  42736. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42737. /**
  42738. * Disposes of the session manager
  42739. */
  42740. dispose(): void;
  42741. /**
  42742. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42743. * @param sessionMode defines the session to test
  42744. * @returns a promise with boolean as final value
  42745. */
  42746. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42747. }
  42748. }
  42749. declare module BABYLON {
  42750. /**
  42751. * WebXR Camera which holds the views for the xrSession
  42752. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42753. */
  42754. export class WebXRCamera extends FreeCamera {
  42755. private _xrSessionManager;
  42756. private _firstFrame;
  42757. private _referenceQuaternion;
  42758. private _referencedPosition;
  42759. private _xrInvPositionCache;
  42760. private _xrInvQuaternionCache;
  42761. /**
  42762. * Should position compensation execute on first frame.
  42763. * This is used when copying the position from a native (non XR) camera
  42764. */
  42765. compensateOnFirstFrame: boolean;
  42766. /**
  42767. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42768. * @param name the name of the camera
  42769. * @param scene the scene to add the camera to
  42770. * @param _xrSessionManager a constructed xr session manager
  42771. */
  42772. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42773. /**
  42774. * Return the user's height, unrelated to the current ground.
  42775. * This will be the y position of this camera, when ground level is 0.
  42776. */
  42777. get realWorldHeight(): number;
  42778. /** @hidden */
  42779. _updateForDualEyeDebugging(): void;
  42780. /**
  42781. * Sets this camera's transformation based on a non-vr camera
  42782. * @param otherCamera the non-vr camera to copy the transformation from
  42783. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42784. */
  42785. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42786. private _updateFromXRSession;
  42787. private _updateNumberOfRigCameras;
  42788. private _updateReferenceSpace;
  42789. private _updateReferenceSpaceOffset;
  42790. }
  42791. }
  42792. declare module BABYLON {
  42793. /**
  42794. * Defining the interface required for a (webxr) feature
  42795. */
  42796. export interface IWebXRFeature extends IDisposable {
  42797. /**
  42798. * Is this feature attached
  42799. */
  42800. attached: boolean;
  42801. /**
  42802. * Should auto-attach be disabled?
  42803. */
  42804. disableAutoAttach: boolean;
  42805. /**
  42806. * Attach the feature to the session
  42807. * Will usually be called by the features manager
  42808. *
  42809. * @param force should attachment be forced (even when already attached)
  42810. * @returns true if successful.
  42811. */
  42812. attach(force?: boolean): boolean;
  42813. /**
  42814. * Detach the feature from the session
  42815. * Will usually be called by the features manager
  42816. *
  42817. * @returns true if successful.
  42818. */
  42819. detach(): boolean;
  42820. }
  42821. /**
  42822. * A list of the currently available features without referencing them
  42823. */
  42824. export class WebXRFeatureName {
  42825. /**
  42826. * The name of the hit test feature
  42827. */
  42828. static HIT_TEST: string;
  42829. /**
  42830. * The name of the anchor system feature
  42831. */
  42832. static ANCHOR_SYSTEM: string;
  42833. /**
  42834. * The name of the background remover feature
  42835. */
  42836. static BACKGROUND_REMOVER: string;
  42837. /**
  42838. * The name of the pointer selection feature
  42839. */
  42840. static POINTER_SELECTION: string;
  42841. /**
  42842. * The name of the teleportation feature
  42843. */
  42844. static TELEPORTATION: string;
  42845. /**
  42846. * The name of the plane detection feature
  42847. */
  42848. static PLANE_DETECTION: string;
  42849. /**
  42850. * physics impostors for xr controllers feature
  42851. */
  42852. static PHYSICS_CONTROLLERS: string;
  42853. }
  42854. /**
  42855. * Defining the constructor of a feature. Used to register the modules.
  42856. */
  42857. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42858. /**
  42859. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42860. * It is mainly used in AR sessions.
  42861. *
  42862. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42863. */
  42864. export class WebXRFeaturesManager implements IDisposable {
  42865. private _xrSessionManager;
  42866. private static readonly _AvailableFeatures;
  42867. /**
  42868. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42869. * Mainly used internally.
  42870. *
  42871. * @param featureName the name of the feature to register
  42872. * @param constructorFunction the function used to construct the module
  42873. * @param version the (babylon) version of the module
  42874. * @param stable is that a stable version of this module
  42875. */
  42876. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42877. /**
  42878. * Returns a constructor of a specific feature.
  42879. *
  42880. * @param featureName the name of the feature to construct
  42881. * @param version the version of the feature to load
  42882. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42883. * @param options optional options provided to the module.
  42884. * @returns a function that, when called, will return a new instance of this feature
  42885. */
  42886. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42887. /**
  42888. * Return the latest unstable version of this feature
  42889. * @param featureName the name of the feature to search
  42890. * @returns the version number. if not found will return -1
  42891. */
  42892. static GetLatestVersionOfFeature(featureName: string): number;
  42893. /**
  42894. * Return the latest stable version of this feature
  42895. * @param featureName the name of the feature to search
  42896. * @returns the version number. if not found will return -1
  42897. */
  42898. static GetStableVersionOfFeature(featureName: string): number;
  42899. /**
  42900. * Can be used to return the list of features currently registered
  42901. *
  42902. * @returns an Array of available features
  42903. */
  42904. static GetAvailableFeatures(): string[];
  42905. /**
  42906. * Gets the versions available for a specific feature
  42907. * @param featureName the name of the feature
  42908. * @returns an array with the available versions
  42909. */
  42910. static GetAvailableVersions(featureName: string): string[];
  42911. private _features;
  42912. /**
  42913. * constructs a new features manages.
  42914. *
  42915. * @param _xrSessionManager an instance of WebXRSessionManager
  42916. */
  42917. constructor(_xrSessionManager: WebXRSessionManager);
  42918. /**
  42919. * Enable a feature using its name and a version. This will enable it in the scene, and will be responsible to attach it when the session starts.
  42920. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  42921. *
  42922. * @param featureName the name of the feature to load or the class of the feature
  42923. * @param version optional version to load. if not provided the latest version will be enabled
  42924. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42925. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42926. * @returns a new constructed feature or throws an error if feature not found.
  42927. */
  42928. enableFeature(featureName: string | {
  42929. Name: string;
  42930. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42931. /**
  42932. * Used to disable an already-enabled feature
  42933. * The feature will be disposed and will be recreated once enabled.
  42934. * @param featureName the feature to disable
  42935. * @returns true if disable was successful
  42936. */
  42937. disableFeature(featureName: string | {
  42938. Name: string;
  42939. }): boolean;
  42940. /**
  42941. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42942. * Can be used during a session to start a feature
  42943. * @param featureName the name of feature to attach
  42944. */
  42945. attachFeature(featureName: string): void;
  42946. /**
  42947. * Can be used inside a session or when the session ends to detach a specific feature
  42948. * @param featureName the name of the feature to detach
  42949. */
  42950. detachFeature(featureName: string): void;
  42951. /**
  42952. * Get the list of enabled features
  42953. * @returns an array of enabled features
  42954. */
  42955. getEnabledFeatures(): string[];
  42956. /**
  42957. * get the implementation of an enabled feature.
  42958. * @param featureName the name of the feature to load
  42959. * @returns the feature class, if found
  42960. */
  42961. getEnabledFeature(featureName: string): IWebXRFeature;
  42962. /**
  42963. * dispose this features manager
  42964. */
  42965. dispose(): void;
  42966. }
  42967. }
  42968. declare module BABYLON {
  42969. /**
  42970. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42971. * @see https://doc.babylonjs.com/how_to/webxr
  42972. */
  42973. export class WebXRExperienceHelper implements IDisposable {
  42974. private scene;
  42975. /**
  42976. * Camera used to render xr content
  42977. */
  42978. camera: WebXRCamera;
  42979. /**
  42980. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42981. */
  42982. state: WebXRState;
  42983. private _setState;
  42984. /**
  42985. * Fires when the state of the experience helper has changed
  42986. */
  42987. onStateChangedObservable: Observable<WebXRState>;
  42988. /**
  42989. * Observers registered here will be triggered after the camera's initial transformation is set
  42990. * This can be used to set a different ground level or an extra rotation.
  42991. *
  42992. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42993. * to the position set after this observable is done executing.
  42994. */
  42995. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42996. /** Session manager used to keep track of xr session */
  42997. sessionManager: WebXRSessionManager;
  42998. /** A features manager for this xr session */
  42999. featuresManager: WebXRFeaturesManager;
  43000. private _nonVRCamera;
  43001. private _originalSceneAutoClear;
  43002. private _supported;
  43003. /**
  43004. * Creates the experience helper
  43005. * @param scene the scene to attach the experience helper to
  43006. * @returns a promise for the experience helper
  43007. */
  43008. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43009. /**
  43010. * Creates a WebXRExperienceHelper
  43011. * @param scene The scene the helper should be created in
  43012. */
  43013. private constructor();
  43014. /**
  43015. * Exits XR mode and returns the scene to its original state
  43016. * @returns promise that resolves after xr mode has exited
  43017. */
  43018. exitXRAsync(): Promise<void>;
  43019. /**
  43020. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43021. * @param sessionMode options for the XR session
  43022. * @param referenceSpaceType frame of reference of the XR session
  43023. * @param renderTarget the output canvas that will be used to enter XR mode
  43024. * @returns promise that resolves after xr mode has entered
  43025. */
  43026. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43027. /**
  43028. * Disposes of the experience helper
  43029. */
  43030. dispose(): void;
  43031. private _nonXRToXRCamera;
  43032. }
  43033. }
  43034. declare module BABYLON {
  43035. /**
  43036. * X-Y values for axes in WebXR
  43037. */
  43038. export interface IWebXRMotionControllerAxesValue {
  43039. /**
  43040. * The value of the x axis
  43041. */
  43042. x: number;
  43043. /**
  43044. * The value of the y-axis
  43045. */
  43046. y: number;
  43047. }
  43048. /**
  43049. * changed / previous values for the values of this component
  43050. */
  43051. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43052. /**
  43053. * current (this frame) value
  43054. */
  43055. current: T;
  43056. /**
  43057. * previous (last change) value
  43058. */
  43059. previous: T;
  43060. }
  43061. /**
  43062. * Represents changes in the component between current frame and last values recorded
  43063. */
  43064. export interface IWebXRMotionControllerComponentChanges {
  43065. /**
  43066. * will be populated with previous and current values if touched changed
  43067. */
  43068. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43069. /**
  43070. * will be populated with previous and current values if pressed changed
  43071. */
  43072. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43073. /**
  43074. * will be populated with previous and current values if value changed
  43075. */
  43076. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43077. /**
  43078. * will be populated with previous and current values if axes changed
  43079. */
  43080. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43081. }
  43082. /**
  43083. * This class represents a single component (for example button or thumbstick) of a motion controller
  43084. */
  43085. export class WebXRControllerComponent implements IDisposable {
  43086. /**
  43087. * the id of this component
  43088. */
  43089. id: string;
  43090. /**
  43091. * the type of the component
  43092. */
  43093. type: MotionControllerComponentType;
  43094. private _buttonIndex;
  43095. private _axesIndices;
  43096. /**
  43097. * Thumbstick component type
  43098. */
  43099. static THUMBSTICK_TYPE: MotionControllerComponentType;
  43100. /**
  43101. * Touchpad component type
  43102. */
  43103. static TOUCHPAD_TYPE: MotionControllerComponentType;
  43104. /**
  43105. * trigger component type
  43106. */
  43107. static TRIGGER_TYPE: MotionControllerComponentType;
  43108. /**
  43109. * squeeze component type
  43110. */
  43111. static SQUEEZE_TYPE: MotionControllerComponentType;
  43112. /**
  43113. * button component type
  43114. */
  43115. static BUTTON_TYPE: MotionControllerComponentType;
  43116. /**
  43117. * Observers registered here will be triggered when the state of a button changes
  43118. * State change is either pressed / touched / value
  43119. */
  43120. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43121. /**
  43122. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43123. * the axes data changes
  43124. */
  43125. onAxisValueChangedObservable: Observable<{
  43126. x: number;
  43127. y: number;
  43128. }>;
  43129. private _currentValue;
  43130. private _touched;
  43131. private _pressed;
  43132. private _axes;
  43133. private _changes;
  43134. private _hasChanges;
  43135. /**
  43136. * Return whether or not the component changed the last frame
  43137. */
  43138. get hasChanges(): boolean;
  43139. /**
  43140. * Creates a new component for a motion controller.
  43141. * It is created by the motion controller itself
  43142. *
  43143. * @param id the id of this component
  43144. * @param type the type of the component
  43145. * @param _buttonIndex index in the buttons array of the gamepad
  43146. * @param _axesIndices indices of the values in the axes array of the gamepad
  43147. */
  43148. constructor(
  43149. /**
  43150. * the id of this component
  43151. */
  43152. id: string,
  43153. /**
  43154. * the type of the component
  43155. */
  43156. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43157. /**
  43158. * Get the current value of this component
  43159. */
  43160. get value(): number;
  43161. /**
  43162. * is the button currently pressed
  43163. */
  43164. get pressed(): boolean;
  43165. /**
  43166. * is the button currently touched
  43167. */
  43168. get touched(): boolean;
  43169. /**
  43170. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43171. */
  43172. get axes(): IWebXRMotionControllerAxesValue;
  43173. /**
  43174. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43175. */
  43176. get changes(): IWebXRMotionControllerComponentChanges;
  43177. /**
  43178. * Is this component a button (hence - pressable)
  43179. * @returns true if can be pressed
  43180. */
  43181. isButton(): boolean;
  43182. /**
  43183. * Are there axes correlating to this component
  43184. * @return true is axes data is available
  43185. */
  43186. isAxes(): boolean;
  43187. /**
  43188. * update this component using the gamepad object it is in. Called on every frame
  43189. * @param nativeController the native gamepad controller object
  43190. */
  43191. update(nativeController: IMinimalMotionControllerObject): void;
  43192. /**
  43193. * Dispose this component
  43194. */
  43195. dispose(): void;
  43196. }
  43197. }
  43198. declare module BABYLON {
  43199. /**
  43200. * Class used to represent data loading progression
  43201. */
  43202. export class SceneLoaderProgressEvent {
  43203. /** defines if data length to load can be evaluated */
  43204. readonly lengthComputable: boolean;
  43205. /** defines the loaded data length */
  43206. readonly loaded: number;
  43207. /** defines the data length to load */
  43208. readonly total: number;
  43209. /**
  43210. * Create a new progress event
  43211. * @param lengthComputable defines if data length to load can be evaluated
  43212. * @param loaded defines the loaded data length
  43213. * @param total defines the data length to load
  43214. */
  43215. constructor(
  43216. /** defines if data length to load can be evaluated */
  43217. lengthComputable: boolean,
  43218. /** defines the loaded data length */
  43219. loaded: number,
  43220. /** defines the data length to load */
  43221. total: number);
  43222. /**
  43223. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43224. * @param event defines the source event
  43225. * @returns a new SceneLoaderProgressEvent
  43226. */
  43227. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43228. }
  43229. /**
  43230. * Interface used by SceneLoader plugins to define supported file extensions
  43231. */
  43232. export interface ISceneLoaderPluginExtensions {
  43233. /**
  43234. * Defines the list of supported extensions
  43235. */
  43236. [extension: string]: {
  43237. isBinary: boolean;
  43238. };
  43239. }
  43240. /**
  43241. * Interface used by SceneLoader plugin factory
  43242. */
  43243. export interface ISceneLoaderPluginFactory {
  43244. /**
  43245. * Defines the name of the factory
  43246. */
  43247. name: string;
  43248. /**
  43249. * Function called to create a new plugin
  43250. * @return the new plugin
  43251. */
  43252. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43253. /**
  43254. * The callback that returns true if the data can be directly loaded.
  43255. * @param data string containing the file data
  43256. * @returns if the data can be loaded directly
  43257. */
  43258. canDirectLoad?(data: string): boolean;
  43259. }
  43260. /**
  43261. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43262. */
  43263. export interface ISceneLoaderPluginBase {
  43264. /**
  43265. * The friendly name of this plugin.
  43266. */
  43267. name: string;
  43268. /**
  43269. * The file extensions supported by this plugin.
  43270. */
  43271. extensions: string | ISceneLoaderPluginExtensions;
  43272. /**
  43273. * The callback called when loading from a url.
  43274. * @param scene scene loading this url
  43275. * @param url url to load
  43276. * @param onSuccess callback called when the file successfully loads
  43277. * @param onProgress callback called while file is loading (if the server supports this mode)
  43278. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43279. * @param onError callback called when the file fails to load
  43280. * @returns a file request object
  43281. */
  43282. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43283. /**
  43284. * The callback called when loading from a file object.
  43285. * @param scene scene loading this file
  43286. * @param file defines the file to load
  43287. * @param onSuccess defines the callback to call when data is loaded
  43288. * @param onProgress defines the callback to call during loading process
  43289. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43290. * @param onError defines the callback to call when an error occurs
  43291. * @returns a file request object
  43292. */
  43293. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43294. /**
  43295. * The callback that returns true if the data can be directly loaded.
  43296. * @param data string containing the file data
  43297. * @returns if the data can be loaded directly
  43298. */
  43299. canDirectLoad?(data: string): boolean;
  43300. /**
  43301. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43302. * @param scene scene loading this data
  43303. * @param data string containing the data
  43304. * @returns data to pass to the plugin
  43305. */
  43306. directLoad?(scene: Scene, data: string): any;
  43307. /**
  43308. * The callback that allows custom handling of the root url based on the response url.
  43309. * @param rootUrl the original root url
  43310. * @param responseURL the response url if available
  43311. * @returns the new root url
  43312. */
  43313. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43314. }
  43315. /**
  43316. * Interface used to define a SceneLoader plugin
  43317. */
  43318. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43319. /**
  43320. * Import meshes into a scene.
  43321. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43322. * @param scene The scene to import into
  43323. * @param data The data to import
  43324. * @param rootUrl The root url for scene and resources
  43325. * @param meshes The meshes array to import into
  43326. * @param particleSystems The particle systems array to import into
  43327. * @param skeletons The skeletons array to import into
  43328. * @param onError The callback when import fails
  43329. * @returns True if successful or false otherwise
  43330. */
  43331. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43332. /**
  43333. * Load into a scene.
  43334. * @param scene The scene to load into
  43335. * @param data The data to import
  43336. * @param rootUrl The root url for scene and resources
  43337. * @param onError The callback when import fails
  43338. * @returns True if successful or false otherwise
  43339. */
  43340. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43341. /**
  43342. * Load into an asset container.
  43343. * @param scene The scene to load into
  43344. * @param data The data to import
  43345. * @param rootUrl The root url for scene and resources
  43346. * @param onError The callback when import fails
  43347. * @returns The loaded asset container
  43348. */
  43349. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43350. }
  43351. /**
  43352. * Interface used to define an async SceneLoader plugin
  43353. */
  43354. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43355. /**
  43356. * Import meshes into a scene.
  43357. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43358. * @param scene The scene to import into
  43359. * @param data The data to import
  43360. * @param rootUrl The root url for scene and resources
  43361. * @param onProgress The callback when the load progresses
  43362. * @param fileName Defines the name of the file to load
  43363. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43364. */
  43365. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43366. meshes: AbstractMesh[];
  43367. particleSystems: IParticleSystem[];
  43368. skeletons: Skeleton[];
  43369. animationGroups: AnimationGroup[];
  43370. }>;
  43371. /**
  43372. * Load into a scene.
  43373. * @param scene The scene to load into
  43374. * @param data The data to import
  43375. * @param rootUrl The root url for scene and resources
  43376. * @param onProgress The callback when the load progresses
  43377. * @param fileName Defines the name of the file to load
  43378. * @returns Nothing
  43379. */
  43380. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43381. /**
  43382. * Load into an asset container.
  43383. * @param scene The scene to load into
  43384. * @param data The data to import
  43385. * @param rootUrl The root url for scene and resources
  43386. * @param onProgress The callback when the load progresses
  43387. * @param fileName Defines the name of the file to load
  43388. * @returns The loaded asset container
  43389. */
  43390. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43391. }
  43392. /**
  43393. * Mode that determines how to handle old animation groups before loading new ones.
  43394. */
  43395. export enum SceneLoaderAnimationGroupLoadingMode {
  43396. /**
  43397. * Reset all old animations to initial state then dispose them.
  43398. */
  43399. Clean = 0,
  43400. /**
  43401. * Stop all old animations.
  43402. */
  43403. Stop = 1,
  43404. /**
  43405. * Restart old animations from first frame.
  43406. */
  43407. Sync = 2,
  43408. /**
  43409. * Old animations remains untouched.
  43410. */
  43411. NoSync = 3
  43412. }
  43413. /**
  43414. * Class used to load scene from various file formats using registered plugins
  43415. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43416. */
  43417. export class SceneLoader {
  43418. /**
  43419. * No logging while loading
  43420. */
  43421. static readonly NO_LOGGING: number;
  43422. /**
  43423. * Minimal logging while loading
  43424. */
  43425. static readonly MINIMAL_LOGGING: number;
  43426. /**
  43427. * Summary logging while loading
  43428. */
  43429. static readonly SUMMARY_LOGGING: number;
  43430. /**
  43431. * Detailled logging while loading
  43432. */
  43433. static readonly DETAILED_LOGGING: number;
  43434. /**
  43435. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43436. */
  43437. static get ForceFullSceneLoadingForIncremental(): boolean;
  43438. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43439. /**
  43440. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43441. */
  43442. static get ShowLoadingScreen(): boolean;
  43443. static set ShowLoadingScreen(value: boolean);
  43444. /**
  43445. * Defines the current logging level (while loading the scene)
  43446. * @ignorenaming
  43447. */
  43448. static get loggingLevel(): number;
  43449. static set loggingLevel(value: number);
  43450. /**
  43451. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43452. */
  43453. static get CleanBoneMatrixWeights(): boolean;
  43454. static set CleanBoneMatrixWeights(value: boolean);
  43455. /**
  43456. * Event raised when a plugin is used to load a scene
  43457. */
  43458. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43459. private static _registeredPlugins;
  43460. private static _getDefaultPlugin;
  43461. private static _getPluginForExtension;
  43462. private static _getPluginForDirectLoad;
  43463. private static _getPluginForFilename;
  43464. private static _getDirectLoad;
  43465. private static _loadData;
  43466. private static _getFileInfo;
  43467. /**
  43468. * Gets a plugin that can load the given extension
  43469. * @param extension defines the extension to load
  43470. * @returns a plugin or null if none works
  43471. */
  43472. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43473. /**
  43474. * Gets a boolean indicating that the given extension can be loaded
  43475. * @param extension defines the extension to load
  43476. * @returns true if the extension is supported
  43477. */
  43478. static IsPluginForExtensionAvailable(extension: string): boolean;
  43479. /**
  43480. * Adds a new plugin to the list of registered plugins
  43481. * @param plugin defines the plugin to add
  43482. */
  43483. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43484. /**
  43485. * Import meshes into a scene
  43486. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43487. * @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)
  43488. * @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)
  43489. * @param scene the instance of BABYLON.Scene to append to
  43490. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43491. * @param onProgress a callback with a progress event for each file being loaded
  43492. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43493. * @param pluginExtension the extension used to determine the plugin
  43494. * @returns The loaded plugin
  43495. */
  43496. 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>;
  43497. /**
  43498. * Import meshes into a scene
  43499. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43500. * @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)
  43501. * @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)
  43502. * @param scene the instance of BABYLON.Scene to append to
  43503. * @param onProgress a callback with a progress event for each file being loaded
  43504. * @param pluginExtension the extension used to determine the plugin
  43505. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43506. */
  43507. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43508. meshes: AbstractMesh[];
  43509. particleSystems: IParticleSystem[];
  43510. skeletons: Skeleton[];
  43511. animationGroups: AnimationGroup[];
  43512. }>;
  43513. /**
  43514. * Load a scene
  43515. * @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)
  43516. * @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)
  43517. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43518. * @param onSuccess a callback with the scene when import succeeds
  43519. * @param onProgress a callback with a progress event for each file being loaded
  43520. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43521. * @param pluginExtension the extension used to determine the plugin
  43522. * @returns The loaded plugin
  43523. */
  43524. 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>;
  43525. /**
  43526. * Load a scene
  43527. * @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)
  43528. * @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)
  43529. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43530. * @param onProgress a callback with a progress event for each file being loaded
  43531. * @param pluginExtension the extension used to determine the plugin
  43532. * @returns The loaded scene
  43533. */
  43534. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43535. /**
  43536. * Append a scene
  43537. * @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)
  43538. * @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)
  43539. * @param scene is the instance of BABYLON.Scene to append to
  43540. * @param onSuccess a callback with the scene when import succeeds
  43541. * @param onProgress a callback with a progress event for each file being loaded
  43542. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43543. * @param pluginExtension the extension used to determine the plugin
  43544. * @returns The loaded plugin
  43545. */
  43546. 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>;
  43547. /**
  43548. * Append a scene
  43549. * @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)
  43550. * @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)
  43551. * @param scene is the instance of BABYLON.Scene to append to
  43552. * @param onProgress a callback with a progress event for each file being loaded
  43553. * @param pluginExtension the extension used to determine the plugin
  43554. * @returns The given scene
  43555. */
  43556. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43557. /**
  43558. * Load a scene into an asset container
  43559. * @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)
  43560. * @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)
  43561. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43562. * @param onSuccess a callback with the scene when import succeeds
  43563. * @param onProgress a callback with a progress event for each file being loaded
  43564. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43565. * @param pluginExtension the extension used to determine the plugin
  43566. * @returns The loaded plugin
  43567. */
  43568. 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>;
  43569. /**
  43570. * Load a scene into an asset container
  43571. * @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)
  43572. * @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)
  43573. * @param scene is the instance of Scene to append to
  43574. * @param onProgress a callback with a progress event for each file being loaded
  43575. * @param pluginExtension the extension used to determine the plugin
  43576. * @returns The loaded asset container
  43577. */
  43578. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43579. /**
  43580. * Import animations from a file into a scene
  43581. * @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)
  43582. * @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)
  43583. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43584. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43585. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43586. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43587. * @param onSuccess a callback with the scene when import succeeds
  43588. * @param onProgress a callback with a progress event for each file being loaded
  43589. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43590. */
  43591. static ImportAnimations(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): void;
  43592. /**
  43593. * Import animations from a file into a scene
  43594. * @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)
  43595. * @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)
  43596. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43597. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43598. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43599. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43600. * @param onSuccess a callback with the scene when import succeeds
  43601. * @param onProgress a callback with a progress event for each file being loaded
  43602. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43603. * @returns the updated scene with imported animations
  43604. */
  43605. static ImportAnimationsAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, overwriteAnimations?: boolean, animationGroupLoadingMode?: SceneLoaderAnimationGroupLoadingMode, targetConverter?: Nullable<(target: any) => any>, onSuccess?: Nullable<(scene: Scene) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>): Promise<Scene>;
  43606. }
  43607. }
  43608. declare module BABYLON {
  43609. /**
  43610. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43611. */
  43612. export type MotionControllerHandness = "none" | "left" | "right";
  43613. /**
  43614. * The type of components available in motion controllers.
  43615. * This is not the name of the component.
  43616. */
  43617. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43618. /**
  43619. * The state of a controller component
  43620. */
  43621. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43622. /**
  43623. * The schema of motion controller layout.
  43624. * No object will be initialized using this interface
  43625. * This is used just to define the profile.
  43626. */
  43627. export interface IMotionControllerLayout {
  43628. /**
  43629. * Defines the main button component id
  43630. */
  43631. selectComponentId: string;
  43632. /**
  43633. * Available components (unsorted)
  43634. */
  43635. components: {
  43636. /**
  43637. * A map of component Ids
  43638. */
  43639. [componentId: string]: {
  43640. /**
  43641. * The type of input the component outputs
  43642. */
  43643. type: MotionControllerComponentType;
  43644. /**
  43645. * The indices of this component in the gamepad object
  43646. */
  43647. gamepadIndices: {
  43648. /**
  43649. * Index of button
  43650. */
  43651. button?: number;
  43652. /**
  43653. * If available, index of x-axis
  43654. */
  43655. xAxis?: number;
  43656. /**
  43657. * If available, index of y-axis
  43658. */
  43659. yAxis?: number;
  43660. };
  43661. /**
  43662. * The mesh's root node name
  43663. */
  43664. rootNodeName: string;
  43665. /**
  43666. * Animation definitions for this model
  43667. */
  43668. visualResponses: {
  43669. [stateKey: string]: {
  43670. /**
  43671. * What property will be animated
  43672. */
  43673. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43674. /**
  43675. * What states influence this visual reponse
  43676. */
  43677. states: MotionControllerComponentStateType[];
  43678. /**
  43679. * Type of animation - movement or visibility
  43680. */
  43681. valueNodeProperty: "transform" | "visibility";
  43682. /**
  43683. * Base node name to move. Its position will be calculated according to the min and max nodes
  43684. */
  43685. valueNodeName?: string;
  43686. /**
  43687. * Minimum movement node
  43688. */
  43689. minNodeName?: string;
  43690. /**
  43691. * Max movement node
  43692. */
  43693. maxNodeName?: string;
  43694. };
  43695. };
  43696. /**
  43697. * If touch enabled, what is the name of node to display user feedback
  43698. */
  43699. touchPointNodeName?: string;
  43700. };
  43701. };
  43702. /**
  43703. * Is it xr standard mapping or not
  43704. */
  43705. gamepadMapping: "" | "xr-standard";
  43706. /**
  43707. * Base root node of this entire model
  43708. */
  43709. rootNodeName: string;
  43710. /**
  43711. * Path to load the assets. Usually relative to the base path
  43712. */
  43713. assetPath: string;
  43714. }
  43715. /**
  43716. * A definition for the layout map in the input profile
  43717. */
  43718. export interface IMotionControllerLayoutMap {
  43719. /**
  43720. * Layouts with handness type as a key
  43721. */
  43722. [handness: string]: IMotionControllerLayout;
  43723. }
  43724. /**
  43725. * The XR Input profile schema
  43726. * Profiles can be found here:
  43727. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43728. */
  43729. export interface IMotionControllerProfile {
  43730. /**
  43731. * The id of this profile
  43732. * correlates to the profile(s) in the xrInput.profiles array
  43733. */
  43734. profileId: string;
  43735. /**
  43736. * fallback profiles for this profileId
  43737. */
  43738. fallbackProfileIds: string[];
  43739. /**
  43740. * The layout map, with handness as key
  43741. */
  43742. layouts: IMotionControllerLayoutMap;
  43743. }
  43744. /**
  43745. * A helper-interface for the 3 meshes needed for controller button animation
  43746. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43747. */
  43748. export interface IMotionControllerButtonMeshMap {
  43749. /**
  43750. * The mesh that will be changed when value changes
  43751. */
  43752. valueMesh: AbstractMesh;
  43753. /**
  43754. * the mesh that defines the pressed value mesh position.
  43755. * This is used to find the max-position of this button
  43756. */
  43757. pressedMesh: AbstractMesh;
  43758. /**
  43759. * the mesh that defines the unpressed value mesh position.
  43760. * This is used to find the min (or initial) position of this button
  43761. */
  43762. unpressedMesh: AbstractMesh;
  43763. }
  43764. /**
  43765. * A helper-interface for the 3 meshes needed for controller axis animation.
  43766. * This will be expanded when touchpad animations are fully supported
  43767. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43768. */
  43769. export interface IMotionControllerMeshMap {
  43770. /**
  43771. * The mesh that will be changed when axis value changes
  43772. */
  43773. valueMesh: AbstractMesh;
  43774. /**
  43775. * the mesh that defines the minimum value mesh position.
  43776. */
  43777. minMesh?: AbstractMesh;
  43778. /**
  43779. * the mesh that defines the maximum value mesh position.
  43780. */
  43781. maxMesh?: AbstractMesh;
  43782. }
  43783. /**
  43784. * The elements needed for change-detection of the gamepad objects in motion controllers
  43785. */
  43786. export interface IMinimalMotionControllerObject {
  43787. /**
  43788. * An array of available buttons
  43789. */
  43790. buttons: Array<{
  43791. /**
  43792. * Value of the button/trigger
  43793. */
  43794. value: number;
  43795. /**
  43796. * If the button/trigger is currently touched
  43797. */
  43798. touched: boolean;
  43799. /**
  43800. * If the button/trigger is currently pressed
  43801. */
  43802. pressed: boolean;
  43803. }>;
  43804. /**
  43805. * Available axes of this controller
  43806. */
  43807. axes: number[];
  43808. }
  43809. /**
  43810. * An Abstract Motion controller
  43811. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43812. * Each component has an observable to check for changes in value and state
  43813. */
  43814. export abstract class WebXRAbstractMotionController implements IDisposable {
  43815. protected scene: Scene;
  43816. protected layout: IMotionControllerLayout;
  43817. /**
  43818. * The gamepad object correlating to this controller
  43819. */
  43820. gamepadObject: IMinimalMotionControllerObject;
  43821. /**
  43822. * handness (left/right/none) of this controller
  43823. */
  43824. handness: MotionControllerHandness;
  43825. /**
  43826. * The profile id of this motion controller
  43827. */
  43828. abstract profileId: string;
  43829. /**
  43830. * A map of components (WebXRControllerComponent) in this motion controller
  43831. * Components have a ComponentType and can also have both button and axis definitions
  43832. */
  43833. readonly components: {
  43834. [id: string]: WebXRControllerComponent;
  43835. };
  43836. /**
  43837. * Observers registered here will be triggered when the model of this controller is done loading
  43838. */
  43839. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43840. /**
  43841. * The root mesh of the model. It is null if the model was not yet initialized
  43842. */
  43843. rootMesh: Nullable<AbstractMesh>;
  43844. /**
  43845. * Disable the model's animation. Can be set at any time.
  43846. */
  43847. disableAnimation: boolean;
  43848. private _modelReady;
  43849. /**
  43850. * constructs a new abstract motion controller
  43851. * @param scene the scene to which the model of the controller will be added
  43852. * @param layout The profile layout to load
  43853. * @param gamepadObject The gamepad object correlating to this controller
  43854. * @param handness handness (left/right/none) of this controller
  43855. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43856. */
  43857. constructor(scene: Scene, layout: IMotionControllerLayout,
  43858. /**
  43859. * The gamepad object correlating to this controller
  43860. */
  43861. gamepadObject: IMinimalMotionControllerObject,
  43862. /**
  43863. * handness (left/right/none) of this controller
  43864. */
  43865. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43866. private _initComponent;
  43867. /**
  43868. * Update this model using the current XRFrame
  43869. * @param xrFrame the current xr frame to use and update the model
  43870. */
  43871. updateFromXRFrame(xrFrame: XRFrame): void;
  43872. /**
  43873. * Get the list of components available in this motion controller
  43874. * @returns an array of strings correlating to available components
  43875. */
  43876. getComponentIds(): string[];
  43877. /**
  43878. * Get the main (Select) component of this controller as defined in the layout
  43879. * @returns the main component of this controller
  43880. */
  43881. getMainComponent(): WebXRControllerComponent;
  43882. /**
  43883. * get a component based an its component id as defined in layout.components
  43884. * @param id the id of the component
  43885. * @returns the component correlates to the id or undefined if not found
  43886. */
  43887. getComponent(id: string): WebXRControllerComponent;
  43888. /**
  43889. * Get the first component of specific type
  43890. * @param type type of component to find
  43891. * @return a controller component or null if not found
  43892. */
  43893. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43894. /**
  43895. * Returns all components of specific type
  43896. * @param type the type to search for
  43897. * @return an array of components with this type
  43898. */
  43899. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43900. /**
  43901. * Loads the model correlating to this controller
  43902. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43903. * @returns A promise fulfilled with the result of the model loading
  43904. */
  43905. loadModel(): Promise<boolean>;
  43906. /**
  43907. * Update the model itself with the current frame data
  43908. * @param xrFrame the frame to use for updating the model mesh
  43909. */
  43910. protected updateModel(xrFrame: XRFrame): void;
  43911. /**
  43912. * Moves the axis on the controller mesh based on its current state
  43913. * @param axis the index of the axis
  43914. * @param axisValue the value of the axis which determines the meshes new position
  43915. * @hidden
  43916. */
  43917. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43918. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43919. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43920. private _getGenericFilenameAndPath;
  43921. private _getGenericParentMesh;
  43922. /**
  43923. * Get the filename and path for this controller's model
  43924. * @returns a map of filename and path
  43925. */
  43926. protected abstract _getFilenameAndPath(): {
  43927. filename: string;
  43928. path: string;
  43929. };
  43930. /**
  43931. * This function will be called after the model was successfully loaded and can be used
  43932. * for mesh transformations before it is available for the user
  43933. * @param meshes the loaded meshes
  43934. */
  43935. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43936. /**
  43937. * Set the root mesh for this controller. Important for the WebXR controller class
  43938. * @param meshes the loaded meshes
  43939. */
  43940. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43941. /**
  43942. * A function executed each frame that updates the mesh (if needed)
  43943. * @param xrFrame the current xrFrame
  43944. */
  43945. protected abstract _updateModel(xrFrame: XRFrame): void;
  43946. /**
  43947. * This function is called before the mesh is loaded. It checks for loading constraints.
  43948. * For example, this function can check if the GLB loader is available
  43949. * If this function returns false, the generic controller will be loaded instead
  43950. * @returns Is the client ready to load the mesh
  43951. */
  43952. protected abstract _getModelLoadingConstraints(): boolean;
  43953. /**
  43954. * Dispose this controller, the model mesh and all its components
  43955. */
  43956. dispose(): void;
  43957. }
  43958. }
  43959. declare module BABYLON {
  43960. /**
  43961. * A generic trigger-only motion controller for WebXR
  43962. */
  43963. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43964. /**
  43965. * Static version of the profile id of this controller
  43966. */
  43967. static ProfileId: string;
  43968. profileId: string;
  43969. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43970. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43971. protected _updateModel(): void;
  43972. protected _getFilenameAndPath(): {
  43973. filename: string;
  43974. path: string;
  43975. };
  43976. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43977. protected _getModelLoadingConstraints(): boolean;
  43978. }
  43979. }
  43980. declare module BABYLON {
  43981. /**
  43982. * Class containing static functions to help procedurally build meshes
  43983. */
  43984. export class SphereBuilder {
  43985. /**
  43986. * Creates a sphere mesh
  43987. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43988. * * 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`)
  43989. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43990. * * 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
  43991. * * 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)
  43992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43993. * * 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
  43994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43995. * @param name defines the name of the mesh
  43996. * @param options defines the options used to create the mesh
  43997. * @param scene defines the hosting scene
  43998. * @returns the sphere mesh
  43999. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44000. */
  44001. static CreateSphere(name: string, options: {
  44002. segments?: number;
  44003. diameter?: number;
  44004. diameterX?: number;
  44005. diameterY?: number;
  44006. diameterZ?: number;
  44007. arc?: number;
  44008. slice?: number;
  44009. sideOrientation?: number;
  44010. frontUVs?: Vector4;
  44011. backUVs?: Vector4;
  44012. updatable?: boolean;
  44013. }, scene?: Nullable<Scene>): Mesh;
  44014. }
  44015. }
  44016. declare module BABYLON {
  44017. /**
  44018. * A profiled motion controller has its profile loaded from an online repository.
  44019. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44020. */
  44021. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44022. private _repositoryUrl;
  44023. /**
  44024. * The profile ID of this controller. Will be populated when the controller initializes.
  44025. */
  44026. profileId: string;
  44027. private _buttonMeshMapping;
  44028. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44029. protected _getFilenameAndPath(): {
  44030. filename: string;
  44031. path: string;
  44032. };
  44033. private _touchDots;
  44034. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44035. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44036. protected _updateModel(_xrFrame: XRFrame): void;
  44037. protected _getModelLoadingConstraints(): boolean;
  44038. dispose(): void;
  44039. }
  44040. }
  44041. declare module BABYLON {
  44042. /**
  44043. * A construction function type to create a new controller based on an xrInput object
  44044. */
  44045. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44046. /**
  44047. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44048. *
  44049. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44050. * it should be replaced with auto-loaded controllers.
  44051. *
  44052. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44053. */
  44054. export class WebXRMotionControllerManager {
  44055. /**
  44056. * The base URL of the online controller repository. Can be changed at any time.
  44057. */
  44058. static BaseRepositoryUrl: string;
  44059. /**
  44060. * Use the online repository, or use only locally-defined controllers
  44061. */
  44062. static UseOnlineRepository: boolean;
  44063. /**
  44064. * Which repository gets priority - local or online
  44065. */
  44066. static PrioritizeOnlineRepository: boolean;
  44067. private static _AvailableControllers;
  44068. private static _Fallbacks;
  44069. /**
  44070. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44071. *
  44072. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44073. *
  44074. * @param type the profile type to register
  44075. * @param constructFunction the function to be called when loading this profile
  44076. */
  44077. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44078. /**
  44079. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44080. * The order of search:
  44081. *
  44082. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44083. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44084. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44085. * 4) return the generic trigger controller if none were found
  44086. *
  44087. * @param xrInput the xrInput to which a new controller is initialized
  44088. * @param scene the scene to which the model will be added
  44089. * @param forceProfile force a certain profile for this controller
  44090. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44091. */
  44092. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44093. private static _LoadProfilesFromAvailableControllers;
  44094. private static _ProfilesList;
  44095. private static _ProfileLoadingPromises;
  44096. private static _LoadProfileFromRepository;
  44097. /**
  44098. * Clear the cache used for profile loading and reload when requested again
  44099. */
  44100. static ClearProfilesCache(): void;
  44101. /**
  44102. * Will update the list of profiles available in the repository
  44103. * @return a promise that resolves to a map of profiles available online
  44104. */
  44105. static UpdateProfilesList(): Promise<{
  44106. [profile: string]: string;
  44107. }>;
  44108. /**
  44109. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44110. * @param profileId the profile to which a fallback needs to be found
  44111. * @return an array with corresponding fallback profiles
  44112. */
  44113. static FindFallbackWithProfileId(profileId: string): string[];
  44114. /**
  44115. * Register a fallback to a specific profile.
  44116. * @param profileId the profileId that will receive the fallbacks
  44117. * @param fallbacks A list of fallback profiles
  44118. */
  44119. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44120. /**
  44121. * Register the default fallbacks.
  44122. * This function is called automatically when this file is imported.
  44123. */
  44124. static DefaultFallbacks(): void;
  44125. }
  44126. }
  44127. declare module BABYLON {
  44128. /**
  44129. * Configuration options for the WebXR controller creation
  44130. */
  44131. export interface IWebXRControllerOptions {
  44132. /**
  44133. * Force a specific controller type for this controller.
  44134. * This can be used when creating your own profile or when testing different controllers
  44135. */
  44136. forceControllerProfile?: string;
  44137. /**
  44138. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44139. */
  44140. doNotLoadControllerMesh?: boolean;
  44141. /**
  44142. * Should the controller mesh be animated when a user interacts with it
  44143. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44144. */
  44145. disableMotionControllerAnimation?: boolean;
  44146. }
  44147. /**
  44148. * Represents an XR controller
  44149. */
  44150. export class WebXRInputSource {
  44151. private _scene;
  44152. /** The underlying input source for the controller */
  44153. inputSource: XRInputSource;
  44154. private _options;
  44155. /**
  44156. * 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
  44157. */
  44158. grip?: AbstractMesh;
  44159. /**
  44160. * Pointer which can be used to select objects or attach a visible laser to
  44161. */
  44162. pointer: AbstractMesh;
  44163. /**
  44164. * If available, this is the gamepad object related to this controller.
  44165. * Using this object it is possible to get click events and trackpad changes of the
  44166. * webxr controller that is currently being used.
  44167. */
  44168. motionController?: WebXRAbstractMotionController;
  44169. /**
  44170. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44171. */
  44172. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44173. /**
  44174. * Will be triggered when the mesh associated with the motion controller is done loading.
  44175. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44176. * A shortened version of controller -> motion controller -> on mesh loaded.
  44177. */
  44178. onMeshLoadedObservable: Observable<AbstractMesh>;
  44179. /**
  44180. * Event that fires when the controller is removed/disposed.
  44181. * The object provided as event data is this controller, after associated assets were disposed.
  44182. * uniqueId is still available.
  44183. */
  44184. onDisposeObservable: Observable<WebXRInputSource>;
  44185. private _tmpQuaternion;
  44186. private _tmpVector;
  44187. private _uniqueId;
  44188. /**
  44189. * Creates the controller
  44190. * @see https://doc.babylonjs.com/how_to/webxr
  44191. * @param _scene the scene which the controller should be associated to
  44192. * @param inputSource the underlying input source for the controller
  44193. * @param _options options for this controller creation
  44194. */
  44195. constructor(_scene: Scene,
  44196. /** The underlying input source for the controller */
  44197. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44198. /**
  44199. * Get this controllers unique id
  44200. */
  44201. get uniqueId(): string;
  44202. /**
  44203. * Updates the controller pose based on the given XRFrame
  44204. * @param xrFrame xr frame to update the pose with
  44205. * @param referenceSpace reference space to use
  44206. */
  44207. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44208. /**
  44209. * Gets a world space ray coming from the pointer or grip
  44210. * @param result the resulting ray
  44211. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44212. */
  44213. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44214. /**
  44215. * Disposes of the object
  44216. */
  44217. dispose(): void;
  44218. }
  44219. }
  44220. declare module BABYLON {
  44221. /**
  44222. * The schema for initialization options of the XR Input class
  44223. */
  44224. export interface IWebXRInputOptions {
  44225. /**
  44226. * If set to true no model will be automatically loaded
  44227. */
  44228. doNotLoadControllerMeshes?: boolean;
  44229. /**
  44230. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44231. * If not found, the xr input profile data will be used.
  44232. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44233. */
  44234. forceInputProfile?: string;
  44235. /**
  44236. * Do not send a request to the controlle repository to load the profile.
  44237. *
  44238. * Instead, use the controllers available in babylon itself.
  44239. */
  44240. disableOnlineControllerRepository?: boolean;
  44241. /**
  44242. * A custom URL for the controllers repository
  44243. */
  44244. customControllersRepositoryURL?: string;
  44245. /**
  44246. * Should the controller model's components not move according to the user input
  44247. */
  44248. disableControllerAnimation?: boolean;
  44249. }
  44250. /**
  44251. * XR input used to track XR inputs such as controllers/rays
  44252. */
  44253. export class WebXRInput implements IDisposable {
  44254. /**
  44255. * the xr session manager for this session
  44256. */
  44257. xrSessionManager: WebXRSessionManager;
  44258. /**
  44259. * the WebXR camera for this session. Mainly used for teleportation
  44260. */
  44261. xrCamera: WebXRCamera;
  44262. private readonly options;
  44263. /**
  44264. * XR controllers being tracked
  44265. */
  44266. controllers: Array<WebXRInputSource>;
  44267. private _frameObserver;
  44268. private _sessionEndedObserver;
  44269. private _sessionInitObserver;
  44270. /**
  44271. * Event when a controller has been connected/added
  44272. */
  44273. onControllerAddedObservable: Observable<WebXRInputSource>;
  44274. /**
  44275. * Event when a controller has been removed/disconnected
  44276. */
  44277. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44278. /**
  44279. * Initializes the WebXRInput
  44280. * @param xrSessionManager the xr session manager for this session
  44281. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44282. * @param options = initialization options for this xr input
  44283. */
  44284. constructor(
  44285. /**
  44286. * the xr session manager for this session
  44287. */
  44288. xrSessionManager: WebXRSessionManager,
  44289. /**
  44290. * the WebXR camera for this session. Mainly used for teleportation
  44291. */
  44292. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44293. private _onInputSourcesChange;
  44294. private _addAndRemoveControllers;
  44295. /**
  44296. * Disposes of the object
  44297. */
  44298. dispose(): void;
  44299. }
  44300. }
  44301. declare module BABYLON {
  44302. /**
  44303. * This is the base class for all WebXR features.
  44304. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44305. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44306. */
  44307. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44308. protected _xrSessionManager: WebXRSessionManager;
  44309. /**
  44310. * Construct a new (abstract) webxr feature
  44311. * @param _xrSessionManager the xr session manager for this feature
  44312. */
  44313. constructor(_xrSessionManager: WebXRSessionManager);
  44314. private _attached;
  44315. private _removeOnDetach;
  44316. /**
  44317. * Is this feature attached
  44318. */
  44319. get attached(): boolean;
  44320. /**
  44321. * Should auto-attach be disabled?
  44322. */
  44323. disableAutoAttach: boolean;
  44324. /**
  44325. * attach this feature
  44326. *
  44327. * @param force should attachment be forced (even when already attached)
  44328. * @returns true if successful, false is failed or already attached
  44329. */
  44330. attach(force?: boolean): boolean;
  44331. /**
  44332. * detach this feature.
  44333. *
  44334. * @returns true if successful, false if failed or already detached
  44335. */
  44336. detach(): boolean;
  44337. /**
  44338. * Dispose this feature and all of the resources attached
  44339. */
  44340. dispose(): void;
  44341. /**
  44342. * Code in this function will be executed on each xrFrame received from the browser.
  44343. * This function will not execute after the feature is detached.
  44344. * @param _xrFrame the current frame
  44345. */
  44346. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44347. /**
  44348. * This is used to register callbacks that will automatically be removed when detach is called.
  44349. * @param observable the observable to which the observer will be attached
  44350. * @param callback the callback to register
  44351. */
  44352. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44353. }
  44354. }
  44355. declare module BABYLON {
  44356. /**
  44357. * Renders a layer on top of an existing scene
  44358. */
  44359. export class UtilityLayerRenderer implements IDisposable {
  44360. /** the original scene that will be rendered on top of */
  44361. originalScene: Scene;
  44362. private _pointerCaptures;
  44363. private _lastPointerEvents;
  44364. private static _DefaultUtilityLayer;
  44365. private static _DefaultKeepDepthUtilityLayer;
  44366. private _sharedGizmoLight;
  44367. private _renderCamera;
  44368. /**
  44369. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44370. * @returns the camera that is used when rendering the utility layer
  44371. */
  44372. getRenderCamera(): Camera;
  44373. /**
  44374. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44375. * @param cam the camera that should be used when rendering the utility layer
  44376. */
  44377. setRenderCamera(cam: Nullable<Camera>): void;
  44378. /**
  44379. * @hidden
  44380. * Light which used by gizmos to get light shading
  44381. */
  44382. _getSharedGizmoLight(): HemisphericLight;
  44383. /**
  44384. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44385. */
  44386. pickUtilitySceneFirst: boolean;
  44387. /**
  44388. * 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)
  44389. */
  44390. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44391. /**
  44392. * 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)
  44393. */
  44394. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44395. /**
  44396. * The scene that is rendered on top of the original scene
  44397. */
  44398. utilityLayerScene: Scene;
  44399. /**
  44400. * If the utility layer should automatically be rendered on top of existing scene
  44401. */
  44402. shouldRender: boolean;
  44403. /**
  44404. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44405. */
  44406. onlyCheckPointerDownEvents: boolean;
  44407. /**
  44408. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44409. */
  44410. processAllEvents: boolean;
  44411. /**
  44412. * Observable raised when the pointer move from the utility layer scene to the main scene
  44413. */
  44414. onPointerOutObservable: Observable<number>;
  44415. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44416. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44417. private _afterRenderObserver;
  44418. private _sceneDisposeObserver;
  44419. private _originalPointerObserver;
  44420. /**
  44421. * Instantiates a UtilityLayerRenderer
  44422. * @param originalScene the original scene that will be rendered on top of
  44423. * @param handleEvents boolean indicating if the utility layer should handle events
  44424. */
  44425. constructor(
  44426. /** the original scene that will be rendered on top of */
  44427. originalScene: Scene, handleEvents?: boolean);
  44428. private _notifyObservers;
  44429. /**
  44430. * Renders the utility layers scene on top of the original scene
  44431. */
  44432. render(): void;
  44433. /**
  44434. * Disposes of the renderer
  44435. */
  44436. dispose(): void;
  44437. private _updateCamera;
  44438. }
  44439. }
  44440. declare module BABYLON {
  44441. /**
  44442. * Options interface for the pointer selection module
  44443. */
  44444. export interface IWebXRControllerPointerSelectionOptions {
  44445. /**
  44446. * the xr input to use with this pointer selection
  44447. */
  44448. xrInput: WebXRInput;
  44449. /**
  44450. * Different button type to use instead of the main component
  44451. */
  44452. overrideButtonId?: string;
  44453. /**
  44454. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44455. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44456. * 3000 means 3 seconds between pointing at something and selecting it
  44457. */
  44458. timeToSelect?: number;
  44459. /**
  44460. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  44461. * If not disabled, the last picked point will be used to execute a pointer up event
  44462. * If disabled, pointer up event will be triggered right after the pointer down event.
  44463. * Used in screen and gaze target ray mode only
  44464. */
  44465. disablePointerUpOnTouchOut: boolean;
  44466. /**
  44467. * For gaze mode (time to select instead of press)
  44468. */
  44469. forceGazeMode: boolean;
  44470. /**
  44471. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  44472. * to start a new countdown to the pointer down event.
  44473. * Defaults to 1.
  44474. */
  44475. gazeModePointerMovedFactor?: number;
  44476. /**
  44477. * Should meshes created here be added to a utility layer or the main scene
  44478. */
  44479. useUtilityLayer?: boolean;
  44480. /**
  44481. * if provided, this scene will be used to render meshes.
  44482. */
  44483. customUtilityLayerScene?: Scene;
  44484. /**
  44485. * use this rendering group id for the meshes (optional)
  44486. */
  44487. renderingGroupId?: number;
  44488. }
  44489. /**
  44490. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44491. */
  44492. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44493. private readonly _options;
  44494. /**
  44495. * The module's name
  44496. */
  44497. static readonly Name: string;
  44498. /**
  44499. * The (Babylon) version of this module.
  44500. * This is an integer representing the implementation version.
  44501. * This number does not correspond to the webxr specs version
  44502. */
  44503. static readonly Version: number;
  44504. /**
  44505. * This color will be set to the laser pointer when selection is triggered
  44506. */
  44507. laserPointerPickedColor: Color3;
  44508. /**
  44509. * This color will be applied to the selection ring when selection is triggered
  44510. */
  44511. selectionMeshPickedColor: Color3;
  44512. /**
  44513. * default color of the selection ring
  44514. */
  44515. selectionMeshDefaultColor: Color3;
  44516. /**
  44517. * Default color of the laser pointer
  44518. */
  44519. lasterPointerDefaultColor: Color3;
  44520. /**
  44521. * Should the laser pointer be displayed
  44522. */
  44523. displayLaserPointer: boolean;
  44524. /**
  44525. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44526. */
  44527. displaySelectionMesh: boolean;
  44528. /**
  44529. * Disable lighting on the laser pointer (so it will always be visible)
  44530. */
  44531. disablePointerLighting: boolean;
  44532. /**
  44533. * Disable lighting on the selection mesh (so it will always be visible)
  44534. */
  44535. disableSelectionMeshLighting: boolean;
  44536. private static _idCounter;
  44537. private _controllers;
  44538. private _scene;
  44539. /**
  44540. * constructs a new background remover module
  44541. * @param _xrSessionManager the session manager for this module
  44542. * @param _options read-only options to be used in this module
  44543. */
  44544. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44545. /**
  44546. * attach this feature
  44547. * Will usually be called by the features manager
  44548. *
  44549. * @returns true if successful.
  44550. */
  44551. attach(): boolean;
  44552. /**
  44553. * detach this feature.
  44554. * Will usually be called by the features manager
  44555. *
  44556. * @returns true if successful.
  44557. */
  44558. detach(): boolean;
  44559. /**
  44560. * Get the xr controller that correlates to the pointer id in the pointer event
  44561. *
  44562. * @param id the pointer id to search for
  44563. * @returns the controller that correlates to this id or null if not found
  44564. */
  44565. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44566. /**
  44567. * Will get the mesh under a specific pointer.
  44568. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  44569. * @param controllerId the controllerId to check
  44570. * @returns The mesh under pointer or null if no mesh is under the pointer
  44571. */
  44572. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  44573. protected _onXRFrame(_xrFrame: XRFrame): void;
  44574. private _attachController;
  44575. private _attachScreenRayMode;
  44576. private _attachGazeMode;
  44577. private _tmpVectorForPickCompare;
  44578. private _pickingMoved;
  44579. private _attachTrackedPointerRayMode;
  44580. private _detachController;
  44581. private _generateNewMeshPair;
  44582. private _convertNormalToDirectionOfRay;
  44583. private _updatePointerDistance;
  44584. }
  44585. }
  44586. declare module BABYLON {
  44587. /**
  44588. * Button which can be used to enter a different mode of XR
  44589. */
  44590. export class WebXREnterExitUIButton {
  44591. /** button element */
  44592. element: HTMLElement;
  44593. /** XR initialization options for the button */
  44594. sessionMode: XRSessionMode;
  44595. /** Reference space type */
  44596. referenceSpaceType: XRReferenceSpaceType;
  44597. /**
  44598. * Creates a WebXREnterExitUIButton
  44599. * @param element button element
  44600. * @param sessionMode XR initialization session mode
  44601. * @param referenceSpaceType the type of reference space to be used
  44602. */
  44603. constructor(
  44604. /** button element */
  44605. element: HTMLElement,
  44606. /** XR initialization options for the button */
  44607. sessionMode: XRSessionMode,
  44608. /** Reference space type */
  44609. referenceSpaceType: XRReferenceSpaceType);
  44610. /**
  44611. * Overwritable function which can be used to update the button's visuals when the state changes
  44612. * @param activeButton the current active button in the UI
  44613. */
  44614. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44615. }
  44616. /**
  44617. * Options to create the webXR UI
  44618. */
  44619. export class WebXREnterExitUIOptions {
  44620. /**
  44621. * Context to enter xr with
  44622. */
  44623. renderTarget?: Nullable<WebXRRenderTarget>;
  44624. /**
  44625. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44626. */
  44627. customButtons?: Array<WebXREnterExitUIButton>;
  44628. /**
  44629. * A session mode to use when creating the default button.
  44630. * Default is immersive-vr
  44631. */
  44632. sessionMode?: XRSessionMode;
  44633. /**
  44634. * A reference space type to use when creating the default button.
  44635. * Default is local-floor
  44636. */
  44637. referenceSpaceType?: XRReferenceSpaceType;
  44638. }
  44639. /**
  44640. * UI to allow the user to enter/exit XR mode
  44641. */
  44642. export class WebXREnterExitUI implements IDisposable {
  44643. private scene;
  44644. /** version of the options passed to this UI */
  44645. options: WebXREnterExitUIOptions;
  44646. private _overlay;
  44647. private _buttons;
  44648. private _activeButton;
  44649. /**
  44650. * Fired every time the active button is changed.
  44651. *
  44652. * When xr is entered via a button that launches xr that button will be the callback parameter
  44653. *
  44654. * When exiting xr the callback parameter will be null)
  44655. */
  44656. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44657. /**
  44658. * Creates UI to allow the user to enter/exit XR mode
  44659. * @param scene the scene to add the ui to
  44660. * @param helper the xr experience helper to enter/exit xr with
  44661. * @param options options to configure the UI
  44662. * @returns the created ui
  44663. */
  44664. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44665. /**
  44666. *
  44667. * @param scene babylon scene object to use
  44668. * @param options (read-only) version of the options passed to this UI
  44669. */
  44670. private constructor();
  44671. private _updateButtons;
  44672. /**
  44673. * Disposes of the object
  44674. */
  44675. dispose(): void;
  44676. }
  44677. }
  44678. declare module BABYLON {
  44679. /**
  44680. * Class containing static functions to help procedurally build meshes
  44681. */
  44682. export class LinesBuilder {
  44683. /**
  44684. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44685. * * 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
  44686. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44687. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44688. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44689. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44690. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44691. * * 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
  44692. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44693. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44694. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44695. * @param name defines the name of the new line system
  44696. * @param options defines the options used to create the line system
  44697. * @param scene defines the hosting scene
  44698. * @returns a new line system mesh
  44699. */
  44700. static CreateLineSystem(name: string, options: {
  44701. lines: Vector3[][];
  44702. updatable?: boolean;
  44703. instance?: Nullable<LinesMesh>;
  44704. colors?: Nullable<Color4[][]>;
  44705. useVertexAlpha?: boolean;
  44706. }, scene: Nullable<Scene>): LinesMesh;
  44707. /**
  44708. * Creates a line mesh
  44709. * 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
  44710. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44711. * * The parameter `points` is an array successive Vector3
  44712. * * 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
  44713. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44714. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44715. * * When updating an instance, remember that only point positions can change, not the number of points
  44716. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44717. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44718. * @param name defines the name of the new line system
  44719. * @param options defines the options used to create the line system
  44720. * @param scene defines the hosting scene
  44721. * @returns a new line mesh
  44722. */
  44723. static CreateLines(name: string, options: {
  44724. points: Vector3[];
  44725. updatable?: boolean;
  44726. instance?: Nullable<LinesMesh>;
  44727. colors?: Color4[];
  44728. useVertexAlpha?: boolean;
  44729. }, scene?: Nullable<Scene>): LinesMesh;
  44730. /**
  44731. * Creates a dashed line mesh
  44732. * * 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
  44733. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44734. * * The parameter `points` is an array successive Vector3
  44735. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44736. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44737. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44738. * * 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
  44739. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44740. * * When updating an instance, remember that only point positions can change, not the number of points
  44741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44742. * @param name defines the name of the mesh
  44743. * @param options defines the options used to create the mesh
  44744. * @param scene defines the hosting scene
  44745. * @returns the dashed line mesh
  44746. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44747. */
  44748. static CreateDashedLines(name: string, options: {
  44749. points: Vector3[];
  44750. dashSize?: number;
  44751. gapSize?: number;
  44752. dashNb?: number;
  44753. updatable?: boolean;
  44754. instance?: LinesMesh;
  44755. useVertexAlpha?: boolean;
  44756. }, scene?: Nullable<Scene>): LinesMesh;
  44757. }
  44758. }
  44759. declare module BABYLON {
  44760. /**
  44761. * The options container for the teleportation module
  44762. */
  44763. export interface IWebXRTeleportationOptions {
  44764. /**
  44765. * Babylon XR Input class for controller
  44766. */
  44767. xrInput: WebXRInput;
  44768. /**
  44769. * A list of meshes to use as floor meshes.
  44770. * Meshes can be added and removed after initializing the feature using the
  44771. * addFloorMesh and removeFloorMesh functions
  44772. * If empty, rotation will still work
  44773. */
  44774. floorMeshes?: AbstractMesh[];
  44775. /**
  44776. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44777. * If you want to support rotation, make sure your mesh has a direction indicator.
  44778. *
  44779. * When left untouched, the default mesh will be initialized.
  44780. */
  44781. teleportationTargetMesh?: AbstractMesh;
  44782. /**
  44783. * An array of points to which the teleportation will snap to.
  44784. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  44785. */
  44786. snapPositions?: Vector3[];
  44787. /**
  44788. * How close should the teleportation ray be in order to snap to position.
  44789. * Default to 0.8 units (meters)
  44790. */
  44791. snapToPositionRadius?: number;
  44792. /**
  44793. * Should teleportation move only to snap points
  44794. */
  44795. snapPointsOnly?: boolean;
  44796. /**
  44797. * Values to configure the default target mesh
  44798. */
  44799. defaultTargetMeshOptions?: {
  44800. /**
  44801. * Fill color of the teleportation area
  44802. */
  44803. teleportationFillColor?: string;
  44804. /**
  44805. * Border color for the teleportation area
  44806. */
  44807. teleportationBorderColor?: string;
  44808. /**
  44809. * Disable the mesh's animation sequence
  44810. */
  44811. disableAnimation?: boolean;
  44812. /**
  44813. * Disable lighting on the material or the ring and arrow
  44814. */
  44815. disableLighting?: boolean;
  44816. /**
  44817. * Override the default material of the torus and arrow
  44818. */
  44819. torusArrowMaterial?: Material;
  44820. };
  44821. /**
  44822. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44823. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44824. */
  44825. useMainComponentOnly?: boolean;
  44826. /**
  44827. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44828. */
  44829. timeToTeleport?: number;
  44830. /**
  44831. * Should meshes created here be added to a utility layer or the main scene
  44832. */
  44833. useUtilityLayer?: boolean;
  44834. /**
  44835. * if provided, this scene will be used to render meshes.
  44836. */
  44837. customUtilityLayerScene?: Scene;
  44838. /**
  44839. * use this rendering group id for the meshes (optional)
  44840. */
  44841. renderingGroupId?: number;
  44842. }
  44843. /**
  44844. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44845. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  44846. * the input of the attached controllers.
  44847. */
  44848. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44849. private _options;
  44850. /**
  44851. * The module's name
  44852. */
  44853. static readonly Name: string;
  44854. /**
  44855. * The (Babylon) version of this module.
  44856. * This is an integer representing the implementation version.
  44857. * This number does not correspond to the webxr specs version
  44858. */
  44859. static readonly Version: number;
  44860. /**
  44861. * Is rotation enabled when moving forward?
  44862. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44863. */
  44864. rotationEnabled: boolean;
  44865. /**
  44866. * Should the module support parabolic ray on top of direct ray
  44867. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44868. * Very helpful when moving between floors / different heights
  44869. */
  44870. parabolicRayEnabled: boolean;
  44871. /**
  44872. * The distance from the user to the inspection point in the direction of the controller
  44873. * A higher number will allow the user to move further
  44874. * defaults to 5 (meters, in xr units)
  44875. */
  44876. parabolicCheckRadius: number;
  44877. /**
  44878. * How much rotation should be applied when rotating right and left
  44879. */
  44880. rotationAngle: number;
  44881. /**
  44882. * Is movement backwards enabled
  44883. */
  44884. backwardsMovementEnabled: boolean;
  44885. /**
  44886. * Distance to travel when moving backwards
  44887. */
  44888. backwardsTeleportationDistance: number;
  44889. /**
  44890. * Add a new mesh to the floor meshes array
  44891. * @param mesh the mesh to use as floor mesh
  44892. */
  44893. addFloorMesh(mesh: AbstractMesh): void;
  44894. /**
  44895. * Remove a mesh from the floor meshes array
  44896. * @param mesh the mesh to remove
  44897. */
  44898. removeFloorMesh(mesh: AbstractMesh): void;
  44899. /**
  44900. * Remove a mesh from the floor meshes array using its name
  44901. * @param name the mesh name to remove
  44902. */
  44903. removeFloorMeshByName(name: string): void;
  44904. private _tmpRay;
  44905. private _tmpVector;
  44906. private _floorMeshes;
  44907. private _snapToPositions;
  44908. private _controllers;
  44909. /**
  44910. * constructs a new anchor system
  44911. * @param _xrSessionManager an instance of WebXRSessionManager
  44912. * @param _options configuration object for this feature
  44913. */
  44914. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44915. private _selectionFeature;
  44916. private _snappedToPoint;
  44917. private _teleportationRingMaterial?;
  44918. /**
  44919. * Get the snapPointsOnly flag
  44920. */
  44921. get snapPointsOnly(): boolean;
  44922. /**
  44923. * Sets the snapPointsOnly flag
  44924. * @param snapToPoints should teleportation be exclusively to snap points
  44925. */
  44926. set snapPointsOnly(snapToPoints: boolean);
  44927. /**
  44928. * Add a new snap-to point to fix teleportation to this position
  44929. * @param newSnapPoint The new Snap-To point
  44930. */
  44931. addSnapPoint(newSnapPoint: Vector3): void;
  44932. /**
  44933. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  44934. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  44935. * @returns was the point found and removed or not
  44936. */
  44937. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  44938. /**
  44939. * This function sets a selection feature that will be disabled when
  44940. * the forward ray is shown and will be reattached when hidden.
  44941. * This is used to remove the selection rays when moving.
  44942. * @param selectionFeature the feature to disable when forward movement is enabled
  44943. */
  44944. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44945. attach(): boolean;
  44946. detach(): boolean;
  44947. dispose(): void;
  44948. protected _onXRFrame(_xrFrame: XRFrame): void;
  44949. private _currentTeleportationControllerId;
  44950. private _attachController;
  44951. private _teleportForward;
  44952. private _detachController;
  44953. private _createDefaultTargetMesh;
  44954. private _setTargetMeshVisibility;
  44955. private _setTargetMeshPosition;
  44956. private _quadraticBezierCurve;
  44957. private _showParabolicPath;
  44958. private _findClosestSnapPointWithRadius;
  44959. }
  44960. }
  44961. declare module BABYLON {
  44962. /**
  44963. * Options for the default xr helper
  44964. */
  44965. export class WebXRDefaultExperienceOptions {
  44966. /**
  44967. * Floor meshes that will be used for teleporting
  44968. */
  44969. floorMeshes?: Array<AbstractMesh>;
  44970. /**
  44971. * Enable or disable default UI to enter XR
  44972. */
  44973. disableDefaultUI?: boolean;
  44974. /**
  44975. * optional configuration for the output canvas
  44976. */
  44977. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44978. /**
  44979. * optional UI options. This can be used among other to change session mode and reference space type
  44980. */
  44981. uiOptions?: WebXREnterExitUIOptions;
  44982. /**
  44983. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44984. */
  44985. inputOptions?: IWebXRInputOptions;
  44986. /**
  44987. * Should teleportation not initialize. defaults to false.
  44988. */
  44989. disableTeleportation?: boolean;
  44990. /**
  44991. * If set to true, the first frame will not be used to reset position
  44992. * The first frame is mainly used when copying transformation from the old camera
  44993. * Mainly used in AR
  44994. */
  44995. ignoreNativeCameraTransformation?: boolean;
  44996. /**
  44997. * When loading teleportation and pointer select, use stable versions instead of latest.
  44998. */
  44999. useStablePlugins?: boolean;
  45000. }
  45001. /**
  45002. * Default experience which provides a similar setup to the previous webVRExperience
  45003. */
  45004. export class WebXRDefaultExperience {
  45005. /**
  45006. * Base experience
  45007. */
  45008. baseExperience: WebXRExperienceHelper;
  45009. /**
  45010. * Input experience extension
  45011. */
  45012. input: WebXRInput;
  45013. /**
  45014. * Enables laser pointer and selection
  45015. */
  45016. pointerSelection: WebXRControllerPointerSelection;
  45017. /**
  45018. * Enables teleportation
  45019. */
  45020. teleportation: WebXRMotionControllerTeleportation;
  45021. /**
  45022. * Enables ui for entering/exiting xr
  45023. */
  45024. enterExitUI: WebXREnterExitUI;
  45025. /**
  45026. * Default target xr should render to
  45027. */
  45028. renderTarget: WebXRRenderTarget;
  45029. /**
  45030. * Creates the default xr experience
  45031. * @param scene scene
  45032. * @param options options for basic configuration
  45033. * @returns resulting WebXRDefaultExperience
  45034. */
  45035. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  45036. private constructor();
  45037. /**
  45038. * DIsposes of the experience helper
  45039. */
  45040. dispose(): void;
  45041. }
  45042. }
  45043. declare module BABYLON {
  45044. /**
  45045. * Options to modify the vr teleportation behavior.
  45046. */
  45047. export interface VRTeleportationOptions {
  45048. /**
  45049. * The name of the mesh which should be used as the teleportation floor. (default: null)
  45050. */
  45051. floorMeshName?: string;
  45052. /**
  45053. * A list of meshes to be used as the teleportation floor. (default: empty)
  45054. */
  45055. floorMeshes?: Mesh[];
  45056. /**
  45057. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  45058. */
  45059. teleportationMode?: number;
  45060. /**
  45061. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45062. */
  45063. teleportationTime?: number;
  45064. /**
  45065. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45066. */
  45067. teleportationSpeed?: number;
  45068. /**
  45069. * The easing function used in the animation or null for Linear. (default CircleEase)
  45070. */
  45071. easingFunction?: EasingFunction;
  45072. }
  45073. /**
  45074. * Options to modify the vr experience helper's behavior.
  45075. */
  45076. export interface VRExperienceHelperOptions extends WebVROptions {
  45077. /**
  45078. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45079. */
  45080. createDeviceOrientationCamera?: boolean;
  45081. /**
  45082. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45083. */
  45084. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45085. /**
  45086. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45087. */
  45088. laserToggle?: boolean;
  45089. /**
  45090. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45091. */
  45092. floorMeshes?: Mesh[];
  45093. /**
  45094. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45095. */
  45096. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45097. /**
  45098. * Defines if WebXR should be used instead of WebVR (if available)
  45099. */
  45100. useXR?: boolean;
  45101. }
  45102. /**
  45103. * Event containing information after VR has been entered
  45104. */
  45105. export class OnAfterEnteringVRObservableEvent {
  45106. /**
  45107. * If entering vr was successful
  45108. */
  45109. success: boolean;
  45110. }
  45111. /**
  45112. * Helps to quickly add VR support to an existing scene.
  45113. * See http://doc.babylonjs.com/how_to/webvr_helper
  45114. */
  45115. export class VRExperienceHelper {
  45116. /** Options to modify the vr experience helper's behavior. */
  45117. webVROptions: VRExperienceHelperOptions;
  45118. private _scene;
  45119. private _position;
  45120. private _btnVR;
  45121. private _btnVRDisplayed;
  45122. private _webVRsupported;
  45123. private _webVRready;
  45124. private _webVRrequesting;
  45125. private _webVRpresenting;
  45126. private _hasEnteredVR;
  45127. private _fullscreenVRpresenting;
  45128. private _inputElement;
  45129. private _webVRCamera;
  45130. private _vrDeviceOrientationCamera;
  45131. private _deviceOrientationCamera;
  45132. private _existingCamera;
  45133. private _onKeyDown;
  45134. private _onVrDisplayPresentChange;
  45135. private _onVRDisplayChanged;
  45136. private _onVRRequestPresentStart;
  45137. private _onVRRequestPresentComplete;
  45138. /**
  45139. * 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)
  45140. */
  45141. enableGazeEvenWhenNoPointerLock: boolean;
  45142. /**
  45143. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45144. */
  45145. exitVROnDoubleTap: boolean;
  45146. /**
  45147. * Observable raised right before entering VR.
  45148. */
  45149. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45150. /**
  45151. * Observable raised when entering VR has completed.
  45152. */
  45153. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45154. /**
  45155. * Observable raised when exiting VR.
  45156. */
  45157. onExitingVRObservable: Observable<VRExperienceHelper>;
  45158. /**
  45159. * Observable raised when controller mesh is loaded.
  45160. */
  45161. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45162. /** Return this.onEnteringVRObservable
  45163. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45164. */
  45165. get onEnteringVR(): Observable<VRExperienceHelper>;
  45166. /** Return this.onExitingVRObservable
  45167. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45168. */
  45169. get onExitingVR(): Observable<VRExperienceHelper>;
  45170. /** Return this.onControllerMeshLoadedObservable
  45171. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45172. */
  45173. get onControllerMeshLoaded(): Observable<WebVRController>;
  45174. private _rayLength;
  45175. private _useCustomVRButton;
  45176. private _teleportationRequested;
  45177. private _teleportActive;
  45178. private _floorMeshName;
  45179. private _floorMeshesCollection;
  45180. private _teleportationMode;
  45181. private _teleportationTime;
  45182. private _teleportationSpeed;
  45183. private _teleportationEasing;
  45184. private _rotationAllowed;
  45185. private _teleportBackwardsVector;
  45186. private _teleportationTarget;
  45187. private _isDefaultTeleportationTarget;
  45188. private _postProcessMove;
  45189. private _teleportationFillColor;
  45190. private _teleportationBorderColor;
  45191. private _rotationAngle;
  45192. private _haloCenter;
  45193. private _cameraGazer;
  45194. private _padSensibilityUp;
  45195. private _padSensibilityDown;
  45196. private _leftController;
  45197. private _rightController;
  45198. private _gazeColor;
  45199. private _laserColor;
  45200. private _pickedLaserColor;
  45201. private _pickedGazeColor;
  45202. /**
  45203. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45204. */
  45205. onNewMeshSelected: Observable<AbstractMesh>;
  45206. /**
  45207. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45208. * This observable will provide the mesh and the controller used to select the mesh
  45209. */
  45210. onMeshSelectedWithController: Observable<{
  45211. mesh: AbstractMesh;
  45212. controller: WebVRController;
  45213. }>;
  45214. /**
  45215. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45216. */
  45217. onNewMeshPicked: Observable<PickingInfo>;
  45218. private _circleEase;
  45219. /**
  45220. * Observable raised before camera teleportation
  45221. */
  45222. onBeforeCameraTeleport: Observable<Vector3>;
  45223. /**
  45224. * Observable raised after camera teleportation
  45225. */
  45226. onAfterCameraTeleport: Observable<Vector3>;
  45227. /**
  45228. * Observable raised when current selected mesh gets unselected
  45229. */
  45230. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45231. private _raySelectionPredicate;
  45232. /**
  45233. * To be optionaly changed by user to define custom ray selection
  45234. */
  45235. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45236. /**
  45237. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45238. */
  45239. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45240. /**
  45241. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45242. */
  45243. teleportationEnabled: boolean;
  45244. private _defaultHeight;
  45245. private _teleportationInitialized;
  45246. private _interactionsEnabled;
  45247. private _interactionsRequested;
  45248. private _displayGaze;
  45249. private _displayLaserPointer;
  45250. /**
  45251. * The mesh used to display where the user is going to teleport.
  45252. */
  45253. get teleportationTarget(): Mesh;
  45254. /**
  45255. * Sets the mesh to be used to display where the user is going to teleport.
  45256. */
  45257. set teleportationTarget(value: Mesh);
  45258. /**
  45259. * 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
  45260. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45261. * See http://doc.babylonjs.com/resources/baking_transformations
  45262. */
  45263. get gazeTrackerMesh(): Mesh;
  45264. set gazeTrackerMesh(value: Mesh);
  45265. /**
  45266. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45267. */
  45268. updateGazeTrackerScale: boolean;
  45269. /**
  45270. * If the gaze trackers color should be updated when selecting meshes
  45271. */
  45272. updateGazeTrackerColor: boolean;
  45273. /**
  45274. * If the controller laser color should be updated when selecting meshes
  45275. */
  45276. updateControllerLaserColor: boolean;
  45277. /**
  45278. * The gaze tracking mesh corresponding to the left controller
  45279. */
  45280. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45281. /**
  45282. * The gaze tracking mesh corresponding to the right controller
  45283. */
  45284. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45285. /**
  45286. * If the ray of the gaze should be displayed.
  45287. */
  45288. get displayGaze(): boolean;
  45289. /**
  45290. * Sets if the ray of the gaze should be displayed.
  45291. */
  45292. set displayGaze(value: boolean);
  45293. /**
  45294. * If the ray of the LaserPointer should be displayed.
  45295. */
  45296. get displayLaserPointer(): boolean;
  45297. /**
  45298. * Sets if the ray of the LaserPointer should be displayed.
  45299. */
  45300. set displayLaserPointer(value: boolean);
  45301. /**
  45302. * The deviceOrientationCamera used as the camera when not in VR.
  45303. */
  45304. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45305. /**
  45306. * Based on the current WebVR support, returns the current VR camera used.
  45307. */
  45308. get currentVRCamera(): Nullable<Camera>;
  45309. /**
  45310. * The webVRCamera which is used when in VR.
  45311. */
  45312. get webVRCamera(): WebVRFreeCamera;
  45313. /**
  45314. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45315. */
  45316. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45317. /**
  45318. * The html button that is used to trigger entering into VR.
  45319. */
  45320. get vrButton(): Nullable<HTMLButtonElement>;
  45321. private get _teleportationRequestInitiated();
  45322. /**
  45323. * Defines whether or not Pointer lock should be requested when switching to
  45324. * full screen.
  45325. */
  45326. requestPointerLockOnFullScreen: boolean;
  45327. /**
  45328. * If asking to force XR, this will be populated with the default xr experience
  45329. */
  45330. xr: WebXRDefaultExperience;
  45331. /**
  45332. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45333. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45334. */
  45335. xrTestDone: boolean;
  45336. /**
  45337. * Instantiates a VRExperienceHelper.
  45338. * Helps to quickly add VR support to an existing scene.
  45339. * @param scene The scene the VRExperienceHelper belongs to.
  45340. * @param webVROptions Options to modify the vr experience helper's behavior.
  45341. */
  45342. constructor(scene: Scene,
  45343. /** Options to modify the vr experience helper's behavior. */
  45344. webVROptions?: VRExperienceHelperOptions);
  45345. private completeVRInit;
  45346. private _onDefaultMeshLoaded;
  45347. private _onResize;
  45348. private _onFullscreenChange;
  45349. /**
  45350. * Gets a value indicating if we are currently in VR mode.
  45351. */
  45352. get isInVRMode(): boolean;
  45353. private onVrDisplayPresentChange;
  45354. private onVRDisplayChanged;
  45355. private moveButtonToBottomRight;
  45356. private displayVRButton;
  45357. private updateButtonVisibility;
  45358. private _cachedAngularSensibility;
  45359. /**
  45360. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45361. * Otherwise, will use the fullscreen API.
  45362. */
  45363. enterVR(): void;
  45364. /**
  45365. * Attempt to exit VR, or fullscreen.
  45366. */
  45367. exitVR(): void;
  45368. /**
  45369. * The position of the vr experience helper.
  45370. */
  45371. get position(): Vector3;
  45372. /**
  45373. * Sets the position of the vr experience helper.
  45374. */
  45375. set position(value: Vector3);
  45376. /**
  45377. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45378. */
  45379. enableInteractions(): void;
  45380. private get _noControllerIsActive();
  45381. private beforeRender;
  45382. private _isTeleportationFloor;
  45383. /**
  45384. * Adds a floor mesh to be used for teleportation.
  45385. * @param floorMesh the mesh to be used for teleportation.
  45386. */
  45387. addFloorMesh(floorMesh: Mesh): void;
  45388. /**
  45389. * Removes a floor mesh from being used for teleportation.
  45390. * @param floorMesh the mesh to be removed.
  45391. */
  45392. removeFloorMesh(floorMesh: Mesh): void;
  45393. /**
  45394. * Enables interactions and teleportation using the VR controllers and gaze.
  45395. * @param vrTeleportationOptions options to modify teleportation behavior.
  45396. */
  45397. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45398. private _onNewGamepadConnected;
  45399. private _tryEnableInteractionOnController;
  45400. private _onNewGamepadDisconnected;
  45401. private _enableInteractionOnController;
  45402. private _checkTeleportWithRay;
  45403. private _checkRotate;
  45404. private _checkTeleportBackwards;
  45405. private _enableTeleportationOnController;
  45406. private _createTeleportationCircles;
  45407. private _displayTeleportationTarget;
  45408. private _hideTeleportationTarget;
  45409. private _rotateCamera;
  45410. private _moveTeleportationSelectorTo;
  45411. private _workingVector;
  45412. private _workingQuaternion;
  45413. private _workingMatrix;
  45414. /**
  45415. * Time Constant Teleportation Mode
  45416. */
  45417. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45418. /**
  45419. * Speed Constant Teleportation Mode
  45420. */
  45421. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45422. /**
  45423. * Teleports the users feet to the desired location
  45424. * @param location The location where the user's feet should be placed
  45425. */
  45426. teleportCamera(location: Vector3): void;
  45427. private _convertNormalToDirectionOfRay;
  45428. private _castRayAndSelectObject;
  45429. private _notifySelectedMeshUnselected;
  45430. /**
  45431. * Permanently set new colors for the laser pointer
  45432. * @param color the new laser color
  45433. * @param pickedColor the new laser color when picked mesh detected
  45434. */
  45435. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45436. /**
  45437. * Set lighting enabled / disabled on the laser pointer of both controllers
  45438. * @param enabled should the lighting be enabled on the laser pointer
  45439. */
  45440. setLaserLightingState(enabled?: boolean): void;
  45441. /**
  45442. * Permanently set new colors for the gaze pointer
  45443. * @param color the new gaze color
  45444. * @param pickedColor the new gaze color when picked mesh detected
  45445. */
  45446. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45447. /**
  45448. * Sets the color of the laser ray from the vr controllers.
  45449. * @param color new color for the ray.
  45450. */
  45451. changeLaserColor(color: Color3): void;
  45452. /**
  45453. * Sets the color of the ray from the vr headsets gaze.
  45454. * @param color new color for the ray.
  45455. */
  45456. changeGazeColor(color: Color3): void;
  45457. /**
  45458. * Exits VR and disposes of the vr experience helper
  45459. */
  45460. dispose(): void;
  45461. /**
  45462. * Gets the name of the VRExperienceHelper class
  45463. * @returns "VRExperienceHelper"
  45464. */
  45465. getClassName(): string;
  45466. }
  45467. }
  45468. declare module BABYLON {
  45469. /**
  45470. * Contains an array of blocks representing the octree
  45471. */
  45472. export interface IOctreeContainer<T> {
  45473. /**
  45474. * Blocks within the octree
  45475. */
  45476. blocks: Array<OctreeBlock<T>>;
  45477. }
  45478. /**
  45479. * Class used to store a cell in an octree
  45480. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45481. */
  45482. export class OctreeBlock<T> {
  45483. /**
  45484. * Gets the content of the current block
  45485. */
  45486. entries: T[];
  45487. /**
  45488. * Gets the list of block children
  45489. */
  45490. blocks: Array<OctreeBlock<T>>;
  45491. private _depth;
  45492. private _maxDepth;
  45493. private _capacity;
  45494. private _minPoint;
  45495. private _maxPoint;
  45496. private _boundingVectors;
  45497. private _creationFunc;
  45498. /**
  45499. * Creates a new block
  45500. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45501. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45502. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45503. * @param depth defines the current depth of this block in the octree
  45504. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45505. * @param creationFunc defines a callback to call when an element is added to the block
  45506. */
  45507. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45508. /**
  45509. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45510. */
  45511. get capacity(): number;
  45512. /**
  45513. * Gets the minimum vector (in world space) of the block's bounding box
  45514. */
  45515. get minPoint(): Vector3;
  45516. /**
  45517. * Gets the maximum vector (in world space) of the block's bounding box
  45518. */
  45519. get maxPoint(): Vector3;
  45520. /**
  45521. * Add a new element to this block
  45522. * @param entry defines the element to add
  45523. */
  45524. addEntry(entry: T): void;
  45525. /**
  45526. * Remove an element from this block
  45527. * @param entry defines the element to remove
  45528. */
  45529. removeEntry(entry: T): void;
  45530. /**
  45531. * Add an array of elements to this block
  45532. * @param entries defines the array of elements to add
  45533. */
  45534. addEntries(entries: T[]): void;
  45535. /**
  45536. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45537. * @param frustumPlanes defines the frustum planes to test
  45538. * @param selection defines the array to store current content if selection is positive
  45539. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45540. */
  45541. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45542. /**
  45543. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45544. * @param sphereCenter defines the bounding sphere center
  45545. * @param sphereRadius defines the bounding sphere radius
  45546. * @param selection defines the array to store current content if selection is positive
  45547. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45548. */
  45549. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45550. /**
  45551. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45552. * @param ray defines the ray to test with
  45553. * @param selection defines the array to store current content if selection is positive
  45554. */
  45555. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45556. /**
  45557. * Subdivide the content into child blocks (this block will then be empty)
  45558. */
  45559. createInnerBlocks(): void;
  45560. /**
  45561. * @hidden
  45562. */
  45563. 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;
  45564. }
  45565. }
  45566. declare module BABYLON {
  45567. /**
  45568. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45569. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45570. */
  45571. export class Octree<T> {
  45572. /** 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.) */
  45573. maxDepth: number;
  45574. /**
  45575. * Blocks within the octree containing objects
  45576. */
  45577. blocks: Array<OctreeBlock<T>>;
  45578. /**
  45579. * Content stored in the octree
  45580. */
  45581. dynamicContent: T[];
  45582. private _maxBlockCapacity;
  45583. private _selectionContent;
  45584. private _creationFunc;
  45585. /**
  45586. * Creates a octree
  45587. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45588. * @param creationFunc function to be used to instatiate the octree
  45589. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45590. * @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.)
  45591. */
  45592. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45593. /** 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.) */
  45594. maxDepth?: number);
  45595. /**
  45596. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45597. * @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);
  45598. * @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);
  45599. * @param entries meshes to be added to the octree blocks
  45600. */
  45601. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45602. /**
  45603. * Adds a mesh to the octree
  45604. * @param entry Mesh to add to the octree
  45605. */
  45606. addMesh(entry: T): void;
  45607. /**
  45608. * Remove an element from the octree
  45609. * @param entry defines the element to remove
  45610. */
  45611. removeMesh(entry: T): void;
  45612. /**
  45613. * Selects an array of meshes within the frustum
  45614. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45615. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45616. * @returns array of meshes within the frustum
  45617. */
  45618. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45619. /**
  45620. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45621. * @param sphereCenter defines the bounding sphere center
  45622. * @param sphereRadius defines the bounding sphere radius
  45623. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45624. * @returns an array of objects that intersect the sphere
  45625. */
  45626. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45627. /**
  45628. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45629. * @param ray defines the ray to test with
  45630. * @returns array of intersected objects
  45631. */
  45632. intersectsRay(ray: Ray): SmartArray<T>;
  45633. /**
  45634. * Adds a mesh into the octree block if it intersects the block
  45635. */
  45636. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45637. /**
  45638. * Adds a submesh into the octree block if it intersects the block
  45639. */
  45640. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45641. }
  45642. }
  45643. declare module BABYLON {
  45644. interface Scene {
  45645. /**
  45646. * @hidden
  45647. * Backing Filed
  45648. */
  45649. _selectionOctree: Octree<AbstractMesh>;
  45650. /**
  45651. * Gets the octree used to boost mesh selection (picking)
  45652. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45653. */
  45654. selectionOctree: Octree<AbstractMesh>;
  45655. /**
  45656. * Creates or updates the octree used to boost selection (picking)
  45657. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45658. * @param maxCapacity defines the maximum capacity per leaf
  45659. * @param maxDepth defines the maximum depth of the octree
  45660. * @returns an octree of AbstractMesh
  45661. */
  45662. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45663. }
  45664. interface AbstractMesh {
  45665. /**
  45666. * @hidden
  45667. * Backing Field
  45668. */
  45669. _submeshesOctree: Octree<SubMesh>;
  45670. /**
  45671. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45672. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45673. * @param maxCapacity defines the maximum size of each block (64 by default)
  45674. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45675. * @returns the new octree
  45676. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45677. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45678. */
  45679. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45680. }
  45681. /**
  45682. * Defines the octree scene component responsible to manage any octrees
  45683. * in a given scene.
  45684. */
  45685. export class OctreeSceneComponent {
  45686. /**
  45687. * The component name help to identify the component in the list of scene components.
  45688. */
  45689. readonly name: string;
  45690. /**
  45691. * The scene the component belongs to.
  45692. */
  45693. scene: Scene;
  45694. /**
  45695. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45696. */
  45697. readonly checksIsEnabled: boolean;
  45698. /**
  45699. * Creates a new instance of the component for the given scene
  45700. * @param scene Defines the scene to register the component in
  45701. */
  45702. constructor(scene: Scene);
  45703. /**
  45704. * Registers the component in a given scene
  45705. */
  45706. register(): void;
  45707. /**
  45708. * Return the list of active meshes
  45709. * @returns the list of active meshes
  45710. */
  45711. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45712. /**
  45713. * Return the list of active sub meshes
  45714. * @param mesh The mesh to get the candidates sub meshes from
  45715. * @returns the list of active sub meshes
  45716. */
  45717. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45718. private _tempRay;
  45719. /**
  45720. * Return the list of sub meshes intersecting with a given local ray
  45721. * @param mesh defines the mesh to find the submesh for
  45722. * @param localRay defines the ray in local space
  45723. * @returns the list of intersecting sub meshes
  45724. */
  45725. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45726. /**
  45727. * Return the list of sub meshes colliding with a collider
  45728. * @param mesh defines the mesh to find the submesh for
  45729. * @param collider defines the collider to evaluate the collision against
  45730. * @returns the list of colliding sub meshes
  45731. */
  45732. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45733. /**
  45734. * Rebuilds the elements related to this component in case of
  45735. * context lost for instance.
  45736. */
  45737. rebuild(): void;
  45738. /**
  45739. * Disposes the component and the associated ressources.
  45740. */
  45741. dispose(): void;
  45742. }
  45743. }
  45744. declare module BABYLON {
  45745. /**
  45746. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45747. */
  45748. export class Gizmo implements IDisposable {
  45749. /** The utility layer the gizmo will be added to */
  45750. gizmoLayer: UtilityLayerRenderer;
  45751. /**
  45752. * The root mesh of the gizmo
  45753. */
  45754. _rootMesh: Mesh;
  45755. private _attachedMesh;
  45756. /**
  45757. * Ratio for the scale of the gizmo (Default: 1)
  45758. */
  45759. scaleRatio: number;
  45760. /**
  45761. * If a custom mesh has been set (Default: false)
  45762. */
  45763. protected _customMeshSet: boolean;
  45764. /**
  45765. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45766. * * When set, interactions will be enabled
  45767. */
  45768. get attachedMesh(): Nullable<AbstractMesh>;
  45769. set attachedMesh(value: Nullable<AbstractMesh>);
  45770. /**
  45771. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45772. * @param mesh The mesh to replace the default mesh of the gizmo
  45773. */
  45774. setCustomMesh(mesh: Mesh): void;
  45775. /**
  45776. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45777. */
  45778. updateGizmoRotationToMatchAttachedMesh: boolean;
  45779. /**
  45780. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45781. */
  45782. updateGizmoPositionToMatchAttachedMesh: boolean;
  45783. /**
  45784. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45785. */
  45786. updateScale: boolean;
  45787. protected _interactionsEnabled: boolean;
  45788. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45789. private _beforeRenderObserver;
  45790. private _tempVector;
  45791. /**
  45792. * Creates a gizmo
  45793. * @param gizmoLayer The utility layer the gizmo will be added to
  45794. */
  45795. constructor(
  45796. /** The utility layer the gizmo will be added to */
  45797. gizmoLayer?: UtilityLayerRenderer);
  45798. /**
  45799. * Updates the gizmo to match the attached mesh's position/rotation
  45800. */
  45801. protected _update(): void;
  45802. /**
  45803. * Disposes of the gizmo
  45804. */
  45805. dispose(): void;
  45806. }
  45807. }
  45808. declare module BABYLON {
  45809. /**
  45810. * Single plane drag gizmo
  45811. */
  45812. export class PlaneDragGizmo extends Gizmo {
  45813. /**
  45814. * Drag behavior responsible for the gizmos dragging interactions
  45815. */
  45816. dragBehavior: PointerDragBehavior;
  45817. private _pointerObserver;
  45818. /**
  45819. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45820. */
  45821. snapDistance: number;
  45822. /**
  45823. * Event that fires each time the gizmo snaps to a new location.
  45824. * * snapDistance is the the change in distance
  45825. */
  45826. onSnapObservable: Observable<{
  45827. snapDistance: number;
  45828. }>;
  45829. private _plane;
  45830. private _coloredMaterial;
  45831. private _hoverMaterial;
  45832. private _isEnabled;
  45833. private _parent;
  45834. /** @hidden */
  45835. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45836. /** @hidden */
  45837. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45838. /**
  45839. * Creates a PlaneDragGizmo
  45840. * @param gizmoLayer The utility layer the gizmo will be added to
  45841. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45842. * @param color The color of the gizmo
  45843. */
  45844. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45845. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45846. /**
  45847. * If the gizmo is enabled
  45848. */
  45849. set isEnabled(value: boolean);
  45850. get isEnabled(): boolean;
  45851. /**
  45852. * Disposes of the gizmo
  45853. */
  45854. dispose(): void;
  45855. }
  45856. }
  45857. declare module BABYLON {
  45858. /**
  45859. * Gizmo that enables dragging a mesh along 3 axis
  45860. */
  45861. export class PositionGizmo extends Gizmo {
  45862. /**
  45863. * Internal gizmo used for interactions on the x axis
  45864. */
  45865. xGizmo: AxisDragGizmo;
  45866. /**
  45867. * Internal gizmo used for interactions on the y axis
  45868. */
  45869. yGizmo: AxisDragGizmo;
  45870. /**
  45871. * Internal gizmo used for interactions on the z axis
  45872. */
  45873. zGizmo: AxisDragGizmo;
  45874. /**
  45875. * Internal gizmo used for interactions on the yz plane
  45876. */
  45877. xPlaneGizmo: PlaneDragGizmo;
  45878. /**
  45879. * Internal gizmo used for interactions on the xz plane
  45880. */
  45881. yPlaneGizmo: PlaneDragGizmo;
  45882. /**
  45883. * Internal gizmo used for interactions on the xy plane
  45884. */
  45885. zPlaneGizmo: PlaneDragGizmo;
  45886. /**
  45887. * private variables
  45888. */
  45889. private _meshAttached;
  45890. private _updateGizmoRotationToMatchAttachedMesh;
  45891. private _snapDistance;
  45892. private _scaleRatio;
  45893. /** Fires an event when any of it's sub gizmos are dragged */
  45894. onDragStartObservable: Observable<unknown>;
  45895. /** Fires an event when any of it's sub gizmos are released from dragging */
  45896. onDragEndObservable: Observable<unknown>;
  45897. /**
  45898. * If set to true, planar drag is enabled
  45899. */
  45900. private _planarGizmoEnabled;
  45901. get attachedMesh(): Nullable<AbstractMesh>;
  45902. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45903. /**
  45904. * Creates a PositionGizmo
  45905. * @param gizmoLayer The utility layer the gizmo will be added to
  45906. */
  45907. constructor(gizmoLayer?: UtilityLayerRenderer);
  45908. /**
  45909. * If the planar drag gizmo is enabled
  45910. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45911. */
  45912. set planarGizmoEnabled(value: boolean);
  45913. get planarGizmoEnabled(): boolean;
  45914. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45915. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45916. /**
  45917. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45918. */
  45919. set snapDistance(value: number);
  45920. get snapDistance(): number;
  45921. /**
  45922. * Ratio for the scale of the gizmo (Default: 1)
  45923. */
  45924. set scaleRatio(value: number);
  45925. get scaleRatio(): number;
  45926. /**
  45927. * Disposes of the gizmo
  45928. */
  45929. dispose(): void;
  45930. /**
  45931. * CustomMeshes are not supported by this gizmo
  45932. * @param mesh The mesh to replace the default mesh of the gizmo
  45933. */
  45934. setCustomMesh(mesh: Mesh): void;
  45935. }
  45936. }
  45937. declare module BABYLON {
  45938. /**
  45939. * Single axis drag gizmo
  45940. */
  45941. export class AxisDragGizmo extends Gizmo {
  45942. /**
  45943. * Drag behavior responsible for the gizmos dragging interactions
  45944. */
  45945. dragBehavior: PointerDragBehavior;
  45946. private _pointerObserver;
  45947. /**
  45948. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45949. */
  45950. snapDistance: number;
  45951. /**
  45952. * Event that fires each time the gizmo snaps to a new location.
  45953. * * snapDistance is the the change in distance
  45954. */
  45955. onSnapObservable: Observable<{
  45956. snapDistance: number;
  45957. }>;
  45958. private _isEnabled;
  45959. private _parent;
  45960. private _arrow;
  45961. private _coloredMaterial;
  45962. private _hoverMaterial;
  45963. /** @hidden */
  45964. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45965. /** @hidden */
  45966. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45967. /**
  45968. * Creates an AxisDragGizmo
  45969. * @param gizmoLayer The utility layer the gizmo will be added to
  45970. * @param dragAxis The axis which the gizmo will be able to drag on
  45971. * @param color The color of the gizmo
  45972. */
  45973. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45974. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45975. /**
  45976. * If the gizmo is enabled
  45977. */
  45978. set isEnabled(value: boolean);
  45979. get isEnabled(): boolean;
  45980. /**
  45981. * Disposes of the gizmo
  45982. */
  45983. dispose(): void;
  45984. }
  45985. }
  45986. declare module BABYLON.Debug {
  45987. /**
  45988. * The Axes viewer will show 3 axes in a specific point in space
  45989. */
  45990. export class AxesViewer {
  45991. private _xAxis;
  45992. private _yAxis;
  45993. private _zAxis;
  45994. private _scaleLinesFactor;
  45995. private _instanced;
  45996. /**
  45997. * Gets the hosting scene
  45998. */
  45999. scene: Scene;
  46000. /**
  46001. * Gets or sets a number used to scale line length
  46002. */
  46003. scaleLines: number;
  46004. /** Gets the node hierarchy used to render x-axis */
  46005. get xAxis(): TransformNode;
  46006. /** Gets the node hierarchy used to render y-axis */
  46007. get yAxis(): TransformNode;
  46008. /** Gets the node hierarchy used to render z-axis */
  46009. get zAxis(): TransformNode;
  46010. /**
  46011. * Creates a new AxesViewer
  46012. * @param scene defines the hosting scene
  46013. * @param scaleLines defines a number used to scale line length (1 by default)
  46014. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46015. * @param xAxis defines the node hierarchy used to render the x-axis
  46016. * @param yAxis defines the node hierarchy used to render the y-axis
  46017. * @param zAxis defines the node hierarchy used to render the z-axis
  46018. */
  46019. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46020. /**
  46021. * Force the viewer to update
  46022. * @param position defines the position of the viewer
  46023. * @param xaxis defines the x axis of the viewer
  46024. * @param yaxis defines the y axis of the viewer
  46025. * @param zaxis defines the z axis of the viewer
  46026. */
  46027. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46028. /**
  46029. * Creates an instance of this axes viewer.
  46030. * @returns a new axes viewer with instanced meshes
  46031. */
  46032. createInstance(): AxesViewer;
  46033. /** Releases resources */
  46034. dispose(): void;
  46035. private static _SetRenderingGroupId;
  46036. }
  46037. }
  46038. declare module BABYLON.Debug {
  46039. /**
  46040. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46041. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46042. */
  46043. export class BoneAxesViewer extends AxesViewer {
  46044. /**
  46045. * Gets or sets the target mesh where to display the axes viewer
  46046. */
  46047. mesh: Nullable<Mesh>;
  46048. /**
  46049. * Gets or sets the target bone where to display the axes viewer
  46050. */
  46051. bone: Nullable<Bone>;
  46052. /** Gets current position */
  46053. pos: Vector3;
  46054. /** Gets direction of X axis */
  46055. xaxis: Vector3;
  46056. /** Gets direction of Y axis */
  46057. yaxis: Vector3;
  46058. /** Gets direction of Z axis */
  46059. zaxis: Vector3;
  46060. /**
  46061. * Creates a new BoneAxesViewer
  46062. * @param scene defines the hosting scene
  46063. * @param bone defines the target bone
  46064. * @param mesh defines the target mesh
  46065. * @param scaleLines defines a scaling factor for line length (1 by default)
  46066. */
  46067. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46068. /**
  46069. * Force the viewer to update
  46070. */
  46071. update(): void;
  46072. /** Releases resources */
  46073. dispose(): void;
  46074. }
  46075. }
  46076. declare module BABYLON {
  46077. /**
  46078. * Interface used to define scene explorer extensibility option
  46079. */
  46080. export interface IExplorerExtensibilityOption {
  46081. /**
  46082. * Define the option label
  46083. */
  46084. label: string;
  46085. /**
  46086. * Defines the action to execute on click
  46087. */
  46088. action: (entity: any) => void;
  46089. }
  46090. /**
  46091. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46092. */
  46093. export interface IExplorerExtensibilityGroup {
  46094. /**
  46095. * Defines a predicate to test if a given type mut be extended
  46096. */
  46097. predicate: (entity: any) => boolean;
  46098. /**
  46099. * Gets the list of options added to a type
  46100. */
  46101. entries: IExplorerExtensibilityOption[];
  46102. }
  46103. /**
  46104. * Interface used to define the options to use to create the Inspector
  46105. */
  46106. export interface IInspectorOptions {
  46107. /**
  46108. * Display in overlay mode (default: false)
  46109. */
  46110. overlay?: boolean;
  46111. /**
  46112. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46113. */
  46114. globalRoot?: HTMLElement;
  46115. /**
  46116. * Display the Scene explorer
  46117. */
  46118. showExplorer?: boolean;
  46119. /**
  46120. * Display the property inspector
  46121. */
  46122. showInspector?: boolean;
  46123. /**
  46124. * Display in embed mode (both panes on the right)
  46125. */
  46126. embedMode?: boolean;
  46127. /**
  46128. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46129. */
  46130. handleResize?: boolean;
  46131. /**
  46132. * Allow the panes to popup (default: true)
  46133. */
  46134. enablePopup?: boolean;
  46135. /**
  46136. * Allow the panes to be closed by users (default: true)
  46137. */
  46138. enableClose?: boolean;
  46139. /**
  46140. * Optional list of extensibility entries
  46141. */
  46142. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46143. /**
  46144. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46145. */
  46146. inspectorURL?: string;
  46147. /**
  46148. * Optional initial tab (default to DebugLayerTab.Properties)
  46149. */
  46150. initialTab?: DebugLayerTab;
  46151. }
  46152. interface Scene {
  46153. /**
  46154. * @hidden
  46155. * Backing field
  46156. */
  46157. _debugLayer: DebugLayer;
  46158. /**
  46159. * Gets the debug layer (aka Inspector) associated with the scene
  46160. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46161. */
  46162. debugLayer: DebugLayer;
  46163. }
  46164. /**
  46165. * Enum of inspector action tab
  46166. */
  46167. export enum DebugLayerTab {
  46168. /**
  46169. * Properties tag (default)
  46170. */
  46171. Properties = 0,
  46172. /**
  46173. * Debug tab
  46174. */
  46175. Debug = 1,
  46176. /**
  46177. * Statistics tab
  46178. */
  46179. Statistics = 2,
  46180. /**
  46181. * Tools tab
  46182. */
  46183. Tools = 3,
  46184. /**
  46185. * Settings tab
  46186. */
  46187. Settings = 4
  46188. }
  46189. /**
  46190. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46191. * what is happening in your scene
  46192. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46193. */
  46194. export class DebugLayer {
  46195. /**
  46196. * Define the url to get the inspector script from.
  46197. * By default it uses the babylonjs CDN.
  46198. * @ignoreNaming
  46199. */
  46200. static InspectorURL: string;
  46201. private _scene;
  46202. private BJSINSPECTOR;
  46203. private _onPropertyChangedObservable?;
  46204. /**
  46205. * Observable triggered when a property is changed through the inspector.
  46206. */
  46207. get onPropertyChangedObservable(): any;
  46208. /**
  46209. * Instantiates a new debug layer.
  46210. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46211. * what is happening in your scene
  46212. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46213. * @param scene Defines the scene to inspect
  46214. */
  46215. constructor(scene: Scene);
  46216. /** Creates the inspector window. */
  46217. private _createInspector;
  46218. /**
  46219. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46220. * @param entity defines the entity to select
  46221. * @param lineContainerTitle defines the specific block to highlight
  46222. */
  46223. select(entity: any, lineContainerTitle?: string): void;
  46224. /** Get the inspector from bundle or global */
  46225. private _getGlobalInspector;
  46226. /**
  46227. * Get if the inspector is visible or not.
  46228. * @returns true if visible otherwise, false
  46229. */
  46230. isVisible(): boolean;
  46231. /**
  46232. * Hide the inspector and close its window.
  46233. */
  46234. hide(): void;
  46235. /**
  46236. * Launch the debugLayer.
  46237. * @param config Define the configuration of the inspector
  46238. * @return a promise fulfilled when the debug layer is visible
  46239. */
  46240. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46241. }
  46242. }
  46243. declare module BABYLON {
  46244. /**
  46245. * Class containing static functions to help procedurally build meshes
  46246. */
  46247. export class BoxBuilder {
  46248. /**
  46249. * Creates a box mesh
  46250. * * The parameter `size` sets the size (float) of each box side (default 1)
  46251. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46252. * * 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)
  46253. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46255. * * 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
  46256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46257. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46258. * @param name defines the name of the mesh
  46259. * @param options defines the options used to create the mesh
  46260. * @param scene defines the hosting scene
  46261. * @returns the box mesh
  46262. */
  46263. static CreateBox(name: string, options: {
  46264. size?: number;
  46265. width?: number;
  46266. height?: number;
  46267. depth?: number;
  46268. faceUV?: Vector4[];
  46269. faceColors?: Color4[];
  46270. sideOrientation?: number;
  46271. frontUVs?: Vector4;
  46272. backUVs?: Vector4;
  46273. wrap?: boolean;
  46274. topBaseAt?: number;
  46275. bottomBaseAt?: number;
  46276. updatable?: boolean;
  46277. }, scene?: Nullable<Scene>): Mesh;
  46278. }
  46279. }
  46280. declare module BABYLON.Debug {
  46281. /**
  46282. * Used to show the physics impostor around the specific mesh
  46283. */
  46284. export class PhysicsViewer {
  46285. /** @hidden */
  46286. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46287. /** @hidden */
  46288. protected _meshes: Array<Nullable<AbstractMesh>>;
  46289. /** @hidden */
  46290. protected _scene: Nullable<Scene>;
  46291. /** @hidden */
  46292. protected _numMeshes: number;
  46293. /** @hidden */
  46294. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46295. private _renderFunction;
  46296. private _utilityLayer;
  46297. private _debugBoxMesh;
  46298. private _debugSphereMesh;
  46299. private _debugCylinderMesh;
  46300. private _debugMaterial;
  46301. private _debugMeshMeshes;
  46302. /**
  46303. * Creates a new PhysicsViewer
  46304. * @param scene defines the hosting scene
  46305. */
  46306. constructor(scene: Scene);
  46307. /** @hidden */
  46308. protected _updateDebugMeshes(): void;
  46309. /**
  46310. * Renders a specified physic impostor
  46311. * @param impostor defines the impostor to render
  46312. * @param targetMesh defines the mesh represented by the impostor
  46313. * @returns the new debug mesh used to render the impostor
  46314. */
  46315. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46316. /**
  46317. * Hides a specified physic impostor
  46318. * @param impostor defines the impostor to hide
  46319. */
  46320. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46321. private _getDebugMaterial;
  46322. private _getDebugBoxMesh;
  46323. private _getDebugSphereMesh;
  46324. private _getDebugCylinderMesh;
  46325. private _getDebugMeshMesh;
  46326. private _getDebugMesh;
  46327. /** Releases all resources */
  46328. dispose(): void;
  46329. }
  46330. }
  46331. declare module BABYLON {
  46332. /**
  46333. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46334. * in order to better appreciate the issue one might have.
  46335. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46336. */
  46337. export class RayHelper {
  46338. /**
  46339. * Defines the ray we are currently tryin to visualize.
  46340. */
  46341. ray: Nullable<Ray>;
  46342. private _renderPoints;
  46343. private _renderLine;
  46344. private _renderFunction;
  46345. private _scene;
  46346. private _updateToMeshFunction;
  46347. private _attachedToMesh;
  46348. private _meshSpaceDirection;
  46349. private _meshSpaceOrigin;
  46350. /**
  46351. * Helper function to create a colored helper in a scene in one line.
  46352. * @param ray Defines the ray we are currently tryin to visualize
  46353. * @param scene Defines the scene the ray is used in
  46354. * @param color Defines the color we want to see the ray in
  46355. * @returns The newly created ray helper.
  46356. */
  46357. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46358. /**
  46359. * Instantiate a new ray helper.
  46360. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46361. * in order to better appreciate the issue one might have.
  46362. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46363. * @param ray Defines the ray we are currently tryin to visualize
  46364. */
  46365. constructor(ray: Ray);
  46366. /**
  46367. * Shows the ray we are willing to debug.
  46368. * @param scene Defines the scene the ray needs to be rendered in
  46369. * @param color Defines the color the ray needs to be rendered in
  46370. */
  46371. show(scene: Scene, color?: Color3): void;
  46372. /**
  46373. * Hides the ray we are debugging.
  46374. */
  46375. hide(): void;
  46376. private _render;
  46377. /**
  46378. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46379. * @param mesh Defines the mesh we want the helper attached to
  46380. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46381. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46382. * @param length Defines the length of the ray
  46383. */
  46384. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46385. /**
  46386. * Detach the ray helper from the mesh it has previously been attached to.
  46387. */
  46388. detachFromMesh(): void;
  46389. private _updateToMesh;
  46390. /**
  46391. * Dispose the helper and release its associated resources.
  46392. */
  46393. dispose(): void;
  46394. }
  46395. }
  46396. declare module BABYLON.Debug {
  46397. /**
  46398. * Class used to render a debug view of a given skeleton
  46399. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46400. */
  46401. export class SkeletonViewer {
  46402. /** defines the skeleton to render */
  46403. skeleton: Skeleton;
  46404. /** defines the mesh attached to the skeleton */
  46405. mesh: AbstractMesh;
  46406. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46407. autoUpdateBonesMatrices: boolean;
  46408. /** defines the rendering group id to use with the viewer */
  46409. renderingGroupId: number;
  46410. /** Gets or sets the color used to render the skeleton */
  46411. color: Color3;
  46412. private _scene;
  46413. private _debugLines;
  46414. private _debugMesh;
  46415. private _isEnabled;
  46416. private _renderFunction;
  46417. private _utilityLayer;
  46418. /**
  46419. * Returns the mesh used to render the bones
  46420. */
  46421. get debugMesh(): Nullable<LinesMesh>;
  46422. /**
  46423. * Creates a new SkeletonViewer
  46424. * @param skeleton defines the skeleton to render
  46425. * @param mesh defines the mesh attached to the skeleton
  46426. * @param scene defines the hosting scene
  46427. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46428. * @param renderingGroupId defines the rendering group id to use with the viewer
  46429. */
  46430. constructor(
  46431. /** defines the skeleton to render */
  46432. skeleton: Skeleton,
  46433. /** defines the mesh attached to the skeleton */
  46434. mesh: AbstractMesh, scene: Scene,
  46435. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46436. autoUpdateBonesMatrices?: boolean,
  46437. /** defines the rendering group id to use with the viewer */
  46438. renderingGroupId?: number);
  46439. /** Gets or sets a boolean indicating if the viewer is enabled */
  46440. set isEnabled(value: boolean);
  46441. get isEnabled(): boolean;
  46442. private _getBonePosition;
  46443. private _getLinesForBonesWithLength;
  46444. private _getLinesForBonesNoLength;
  46445. /** Update the viewer to sync with current skeleton state */
  46446. update(): void;
  46447. /** Release associated resources */
  46448. dispose(): void;
  46449. }
  46450. }
  46451. declare module BABYLON {
  46452. /**
  46453. * Options to create the null engine
  46454. */
  46455. export class NullEngineOptions {
  46456. /**
  46457. * Render width (Default: 512)
  46458. */
  46459. renderWidth: number;
  46460. /**
  46461. * Render height (Default: 256)
  46462. */
  46463. renderHeight: number;
  46464. /**
  46465. * Texture size (Default: 512)
  46466. */
  46467. textureSize: number;
  46468. /**
  46469. * If delta time between frames should be constant
  46470. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46471. */
  46472. deterministicLockstep: boolean;
  46473. /**
  46474. * Maximum about of steps between frames (Default: 4)
  46475. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46476. */
  46477. lockstepMaxSteps: number;
  46478. }
  46479. /**
  46480. * The null engine class provides support for headless version of babylon.js.
  46481. * This can be used in server side scenario or for testing purposes
  46482. */
  46483. export class NullEngine extends Engine {
  46484. private _options;
  46485. /**
  46486. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46487. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46488. * @returns true if engine is in deterministic lock step mode
  46489. */
  46490. isDeterministicLockStep(): boolean;
  46491. /**
  46492. * Gets the max steps when engine is running in deterministic lock step
  46493. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46494. * @returns the max steps
  46495. */
  46496. getLockstepMaxSteps(): number;
  46497. /**
  46498. * Gets the current hardware scaling level.
  46499. * By default the hardware scaling level is computed from the window device ratio.
  46500. * 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.
  46501. * @returns a number indicating the current hardware scaling level
  46502. */
  46503. getHardwareScalingLevel(): number;
  46504. constructor(options?: NullEngineOptions);
  46505. /**
  46506. * Creates a vertex buffer
  46507. * @param vertices the data for the vertex buffer
  46508. * @returns the new WebGL static buffer
  46509. */
  46510. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46511. /**
  46512. * Creates a new index buffer
  46513. * @param indices defines the content of the index buffer
  46514. * @param updatable defines if the index buffer must be updatable
  46515. * @returns a new webGL buffer
  46516. */
  46517. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46518. /**
  46519. * Clear the current render buffer or the current render target (if any is set up)
  46520. * @param color defines the color to use
  46521. * @param backBuffer defines if the back buffer must be cleared
  46522. * @param depth defines if the depth buffer must be cleared
  46523. * @param stencil defines if the stencil buffer must be cleared
  46524. */
  46525. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46526. /**
  46527. * Gets the current render width
  46528. * @param useScreen defines if screen size must be used (or the current render target if any)
  46529. * @returns a number defining the current render width
  46530. */
  46531. getRenderWidth(useScreen?: boolean): number;
  46532. /**
  46533. * Gets the current render height
  46534. * @param useScreen defines if screen size must be used (or the current render target if any)
  46535. * @returns a number defining the current render height
  46536. */
  46537. getRenderHeight(useScreen?: boolean): number;
  46538. /**
  46539. * Set the WebGL's viewport
  46540. * @param viewport defines the viewport element to be used
  46541. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46542. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46543. */
  46544. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46545. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46546. /**
  46547. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46548. * @param pipelineContext defines the pipeline context to use
  46549. * @param uniformsNames defines the list of uniform names
  46550. * @returns an array of webGL uniform locations
  46551. */
  46552. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46553. /**
  46554. * Gets the lsit of active attributes for a given webGL program
  46555. * @param pipelineContext defines the pipeline context to use
  46556. * @param attributesNames defines the list of attribute names to get
  46557. * @returns an array of indices indicating the offset of each attribute
  46558. */
  46559. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46560. /**
  46561. * Binds an effect to the webGL context
  46562. * @param effect defines the effect to bind
  46563. */
  46564. bindSamplers(effect: Effect): void;
  46565. /**
  46566. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46567. * @param effect defines the effect to activate
  46568. */
  46569. enableEffect(effect: Effect): void;
  46570. /**
  46571. * Set various states to the webGL context
  46572. * @param culling defines backface culling state
  46573. * @param zOffset defines the value to apply to zOffset (0 by default)
  46574. * @param force defines if states must be applied even if cache is up to date
  46575. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46576. */
  46577. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46578. /**
  46579. * Set the value of an uniform to an array of int32
  46580. * @param uniform defines the webGL uniform location where to store the value
  46581. * @param array defines the array of int32 to store
  46582. */
  46583. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46584. /**
  46585. * Set the value of an uniform to an array of int32 (stored as vec2)
  46586. * @param uniform defines the webGL uniform location where to store the value
  46587. * @param array defines the array of int32 to store
  46588. */
  46589. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46590. /**
  46591. * Set the value of an uniform to an array of int32 (stored as vec3)
  46592. * @param uniform defines the webGL uniform location where to store the value
  46593. * @param array defines the array of int32 to store
  46594. */
  46595. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46596. /**
  46597. * Set the value of an uniform to an array of int32 (stored as vec4)
  46598. * @param uniform defines the webGL uniform location where to store the value
  46599. * @param array defines the array of int32 to store
  46600. */
  46601. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46602. /**
  46603. * Set the value of an uniform to an array of float32
  46604. * @param uniform defines the webGL uniform location where to store the value
  46605. * @param array defines the array of float32 to store
  46606. */
  46607. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46608. /**
  46609. * Set the value of an uniform to an array of float32 (stored as vec2)
  46610. * @param uniform defines the webGL uniform location where to store the value
  46611. * @param array defines the array of float32 to store
  46612. */
  46613. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46614. /**
  46615. * Set the value of an uniform to an array of float32 (stored as vec3)
  46616. * @param uniform defines the webGL uniform location where to store the value
  46617. * @param array defines the array of float32 to store
  46618. */
  46619. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46620. /**
  46621. * Set the value of an uniform to an array of float32 (stored as vec4)
  46622. * @param uniform defines the webGL uniform location where to store the value
  46623. * @param array defines the array of float32 to store
  46624. */
  46625. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46626. /**
  46627. * Set the value of an uniform to an array of number
  46628. * @param uniform defines the webGL uniform location where to store the value
  46629. * @param array defines the array of number to store
  46630. */
  46631. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46632. /**
  46633. * Set the value of an uniform to an array of number (stored as vec2)
  46634. * @param uniform defines the webGL uniform location where to store the value
  46635. * @param array defines the array of number to store
  46636. */
  46637. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46638. /**
  46639. * Set the value of an uniform to an array of number (stored as vec3)
  46640. * @param uniform defines the webGL uniform location where to store the value
  46641. * @param array defines the array of number to store
  46642. */
  46643. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46644. /**
  46645. * Set the value of an uniform to an array of number (stored as vec4)
  46646. * @param uniform defines the webGL uniform location where to store the value
  46647. * @param array defines the array of number to store
  46648. */
  46649. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46650. /**
  46651. * Set the value of an uniform to an array of float32 (stored as matrices)
  46652. * @param uniform defines the webGL uniform location where to store the value
  46653. * @param matrices defines the array of float32 to store
  46654. */
  46655. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46656. /**
  46657. * Set the value of an uniform to a matrix (3x3)
  46658. * @param uniform defines the webGL uniform location where to store the value
  46659. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46660. */
  46661. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46662. /**
  46663. * Set the value of an uniform to a matrix (2x2)
  46664. * @param uniform defines the webGL uniform location where to store the value
  46665. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46666. */
  46667. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46668. /**
  46669. * Set the value of an uniform to a number (float)
  46670. * @param uniform defines the webGL uniform location where to store the value
  46671. * @param value defines the float number to store
  46672. */
  46673. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46674. /**
  46675. * Set the value of an uniform to a vec2
  46676. * @param uniform defines the webGL uniform location where to store the value
  46677. * @param x defines the 1st component of the value
  46678. * @param y defines the 2nd component of the value
  46679. */
  46680. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46681. /**
  46682. * Set the value of an uniform to a vec3
  46683. * @param uniform defines the webGL uniform location where to store the value
  46684. * @param x defines the 1st component of the value
  46685. * @param y defines the 2nd component of the value
  46686. * @param z defines the 3rd component of the value
  46687. */
  46688. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46689. /**
  46690. * Set the value of an uniform to a boolean
  46691. * @param uniform defines the webGL uniform location where to store the value
  46692. * @param bool defines the boolean to store
  46693. */
  46694. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46695. /**
  46696. * Set the value of an uniform to a vec4
  46697. * @param uniform defines the webGL uniform location where to store the value
  46698. * @param x defines the 1st component of the value
  46699. * @param y defines the 2nd component of the value
  46700. * @param z defines the 3rd component of the value
  46701. * @param w defines the 4th component of the value
  46702. */
  46703. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46704. /**
  46705. * Sets the current alpha mode
  46706. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46707. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46708. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46709. */
  46710. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46711. /**
  46712. * Bind webGl buffers directly to the webGL context
  46713. * @param vertexBuffers defines the vertex buffer to bind
  46714. * @param indexBuffer defines the index buffer to bind
  46715. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46716. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46717. * @param effect defines the effect associated with the vertex buffer
  46718. */
  46719. bindBuffers(vertexBuffers: {
  46720. [key: string]: VertexBuffer;
  46721. }, indexBuffer: DataBuffer, effect: Effect): void;
  46722. /**
  46723. * Force the entire cache to be cleared
  46724. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46725. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46726. */
  46727. wipeCaches(bruteForce?: boolean): void;
  46728. /**
  46729. * Send a draw order
  46730. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46731. * @param indexStart defines the starting index
  46732. * @param indexCount defines the number of index to draw
  46733. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46734. */
  46735. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46736. /**
  46737. * Draw a list of indexed primitives
  46738. * @param fillMode defines the primitive to use
  46739. * @param indexStart defines the starting index
  46740. * @param indexCount defines the number of index to draw
  46741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46742. */
  46743. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46744. /**
  46745. * Draw a list of unindexed primitives
  46746. * @param fillMode defines the primitive to use
  46747. * @param verticesStart defines the index of first vertex to draw
  46748. * @param verticesCount defines the count of vertices to draw
  46749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46750. */
  46751. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46752. /** @hidden */
  46753. _createTexture(): WebGLTexture;
  46754. /** @hidden */
  46755. _releaseTexture(texture: InternalTexture): void;
  46756. /**
  46757. * Usually called from Texture.ts.
  46758. * Passed information to create a WebGLTexture
  46759. * @param urlArg defines a value which contains one of the following:
  46760. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46761. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46762. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46763. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46764. * @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)
  46765. * @param scene needed for loading to the correct scene
  46766. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46767. * @param onLoad optional callback to be called upon successful completion
  46768. * @param onError optional callback to be called upon failure
  46769. * @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
  46770. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46771. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46772. * @param forcedExtension defines the extension to use to pick the right loader
  46773. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46774. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46775. */
  46776. 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;
  46777. /**
  46778. * Creates a new render target texture
  46779. * @param size defines the size of the texture
  46780. * @param options defines the options used to create the texture
  46781. * @returns a new render target texture stored in an InternalTexture
  46782. */
  46783. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46784. /**
  46785. * Update the sampling mode of a given texture
  46786. * @param samplingMode defines the required sampling mode
  46787. * @param texture defines the texture to update
  46788. */
  46789. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46790. /**
  46791. * Binds the frame buffer to the specified texture.
  46792. * @param texture The texture to render to or null for the default canvas
  46793. * @param faceIndex The face of the texture to render to in case of cube texture
  46794. * @param requiredWidth The width of the target to render to
  46795. * @param requiredHeight The height of the target to render to
  46796. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46797. * @param lodLevel defines le lod level to bind to the frame buffer
  46798. */
  46799. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46800. /**
  46801. * Unbind the current render target texture from the webGL context
  46802. * @param texture defines the render target texture to unbind
  46803. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46804. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46805. */
  46806. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46807. /**
  46808. * Creates a dynamic vertex buffer
  46809. * @param vertices the data for the dynamic vertex buffer
  46810. * @returns the new WebGL dynamic buffer
  46811. */
  46812. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46813. /**
  46814. * Update the content of a dynamic texture
  46815. * @param texture defines the texture to update
  46816. * @param canvas defines the canvas containing the source
  46817. * @param invertY defines if data must be stored with Y axis inverted
  46818. * @param premulAlpha defines if alpha is stored as premultiplied
  46819. * @param format defines the format of the data
  46820. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46821. */
  46822. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46823. /**
  46824. * Gets a boolean indicating if all created effects are ready
  46825. * @returns true if all effects are ready
  46826. */
  46827. areAllEffectsReady(): boolean;
  46828. /**
  46829. * @hidden
  46830. * Get the current error code of the webGL context
  46831. * @returns the error code
  46832. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46833. */
  46834. getError(): number;
  46835. /** @hidden */
  46836. _getUnpackAlignement(): number;
  46837. /** @hidden */
  46838. _unpackFlipY(value: boolean): void;
  46839. /**
  46840. * Update a dynamic index buffer
  46841. * @param indexBuffer defines the target index buffer
  46842. * @param indices defines the data to update
  46843. * @param offset defines the offset in the target index buffer where update should start
  46844. */
  46845. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46846. /**
  46847. * Updates a dynamic vertex buffer.
  46848. * @param vertexBuffer the vertex buffer to update
  46849. * @param vertices the data used to update the vertex buffer
  46850. * @param byteOffset the byte offset of the data (optional)
  46851. * @param byteLength the byte length of the data (optional)
  46852. */
  46853. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46854. /** @hidden */
  46855. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46856. /** @hidden */
  46857. _bindTexture(channel: number, texture: InternalTexture): void;
  46858. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46859. /**
  46860. * 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
  46861. */
  46862. releaseEffects(): void;
  46863. displayLoadingUI(): void;
  46864. hideLoadingUI(): void;
  46865. /** @hidden */
  46866. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46867. /** @hidden */
  46868. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46869. /** @hidden */
  46870. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46871. /** @hidden */
  46872. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46873. }
  46874. }
  46875. declare module BABYLON {
  46876. /**
  46877. * @hidden
  46878. **/
  46879. export class _TimeToken {
  46880. _startTimeQuery: Nullable<WebGLQuery>;
  46881. _endTimeQuery: Nullable<WebGLQuery>;
  46882. _timeElapsedQuery: Nullable<WebGLQuery>;
  46883. _timeElapsedQueryEnded: boolean;
  46884. }
  46885. }
  46886. declare module BABYLON {
  46887. /** @hidden */
  46888. export class _OcclusionDataStorage {
  46889. /** @hidden */
  46890. occlusionInternalRetryCounter: number;
  46891. /** @hidden */
  46892. isOcclusionQueryInProgress: boolean;
  46893. /** @hidden */
  46894. isOccluded: boolean;
  46895. /** @hidden */
  46896. occlusionRetryCount: number;
  46897. /** @hidden */
  46898. occlusionType: number;
  46899. /** @hidden */
  46900. occlusionQueryAlgorithmType: number;
  46901. }
  46902. interface Engine {
  46903. /**
  46904. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46905. * @return the new query
  46906. */
  46907. createQuery(): WebGLQuery;
  46908. /**
  46909. * Delete and release a webGL query
  46910. * @param query defines the query to delete
  46911. * @return the current engine
  46912. */
  46913. deleteQuery(query: WebGLQuery): Engine;
  46914. /**
  46915. * Check if a given query has resolved and got its value
  46916. * @param query defines the query to check
  46917. * @returns true if the query got its value
  46918. */
  46919. isQueryResultAvailable(query: WebGLQuery): boolean;
  46920. /**
  46921. * Gets the value of a given query
  46922. * @param query defines the query to check
  46923. * @returns the value of the query
  46924. */
  46925. getQueryResult(query: WebGLQuery): number;
  46926. /**
  46927. * Initiates an occlusion query
  46928. * @param algorithmType defines the algorithm to use
  46929. * @param query defines the query to use
  46930. * @returns the current engine
  46931. * @see http://doc.babylonjs.com/features/occlusionquery
  46932. */
  46933. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46934. /**
  46935. * Ends an occlusion query
  46936. * @see http://doc.babylonjs.com/features/occlusionquery
  46937. * @param algorithmType defines the algorithm to use
  46938. * @returns the current engine
  46939. */
  46940. endOcclusionQuery(algorithmType: number): Engine;
  46941. /**
  46942. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46943. * Please note that only one query can be issued at a time
  46944. * @returns a time token used to track the time span
  46945. */
  46946. startTimeQuery(): Nullable<_TimeToken>;
  46947. /**
  46948. * Ends a time query
  46949. * @param token defines the token used to measure the time span
  46950. * @returns the time spent (in ns)
  46951. */
  46952. endTimeQuery(token: _TimeToken): int;
  46953. /** @hidden */
  46954. _currentNonTimestampToken: Nullable<_TimeToken>;
  46955. /** @hidden */
  46956. _createTimeQuery(): WebGLQuery;
  46957. /** @hidden */
  46958. _deleteTimeQuery(query: WebGLQuery): void;
  46959. /** @hidden */
  46960. _getGlAlgorithmType(algorithmType: number): number;
  46961. /** @hidden */
  46962. _getTimeQueryResult(query: WebGLQuery): any;
  46963. /** @hidden */
  46964. _getTimeQueryAvailability(query: WebGLQuery): any;
  46965. }
  46966. interface AbstractMesh {
  46967. /**
  46968. * Backing filed
  46969. * @hidden
  46970. */
  46971. __occlusionDataStorage: _OcclusionDataStorage;
  46972. /**
  46973. * Access property
  46974. * @hidden
  46975. */
  46976. _occlusionDataStorage: _OcclusionDataStorage;
  46977. /**
  46978. * 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.
  46979. * The default value is -1 which means don't break the query and wait till the result
  46980. * @see http://doc.babylonjs.com/features/occlusionquery
  46981. */
  46982. occlusionRetryCount: number;
  46983. /**
  46984. * 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:
  46985. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46986. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46987. * * 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.
  46988. * @see http://doc.babylonjs.com/features/occlusionquery
  46989. */
  46990. occlusionType: number;
  46991. /**
  46992. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46993. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46994. * * 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.
  46995. * @see http://doc.babylonjs.com/features/occlusionquery
  46996. */
  46997. occlusionQueryAlgorithmType: number;
  46998. /**
  46999. * 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
  47000. * @see http://doc.babylonjs.com/features/occlusionquery
  47001. */
  47002. isOccluded: boolean;
  47003. /**
  47004. * Flag to check the progress status of the query
  47005. * @see http://doc.babylonjs.com/features/occlusionquery
  47006. */
  47007. isOcclusionQueryInProgress: boolean;
  47008. }
  47009. }
  47010. declare module BABYLON {
  47011. /** @hidden */
  47012. export var _forceTransformFeedbackToBundle: boolean;
  47013. interface Engine {
  47014. /**
  47015. * Creates a webGL transform feedback object
  47016. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47017. * @returns the webGL transform feedback object
  47018. */
  47019. createTransformFeedback(): WebGLTransformFeedback;
  47020. /**
  47021. * Delete a webGL transform feedback object
  47022. * @param value defines the webGL transform feedback object to delete
  47023. */
  47024. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47025. /**
  47026. * Bind a webGL transform feedback object to the webgl context
  47027. * @param value defines the webGL transform feedback object to bind
  47028. */
  47029. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47030. /**
  47031. * Begins a transform feedback operation
  47032. * @param usePoints defines if points or triangles must be used
  47033. */
  47034. beginTransformFeedback(usePoints: boolean): void;
  47035. /**
  47036. * Ends a transform feedback operation
  47037. */
  47038. endTransformFeedback(): void;
  47039. /**
  47040. * Specify the varyings to use with transform feedback
  47041. * @param program defines the associated webGL program
  47042. * @param value defines the list of strings representing the varying names
  47043. */
  47044. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47045. /**
  47046. * Bind a webGL buffer for a transform feedback operation
  47047. * @param value defines the webGL buffer to bind
  47048. */
  47049. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47050. }
  47051. }
  47052. declare module BABYLON {
  47053. /**
  47054. * Creation options of the multi render target texture.
  47055. */
  47056. export interface IMultiRenderTargetOptions {
  47057. /**
  47058. * Define if the texture needs to create mip maps after render.
  47059. */
  47060. generateMipMaps?: boolean;
  47061. /**
  47062. * Define the types of all the draw buffers we want to create
  47063. */
  47064. types?: number[];
  47065. /**
  47066. * Define the sampling modes of all the draw buffers we want to create
  47067. */
  47068. samplingModes?: number[];
  47069. /**
  47070. * Define if a depth buffer is required
  47071. */
  47072. generateDepthBuffer?: boolean;
  47073. /**
  47074. * Define if a stencil buffer is required
  47075. */
  47076. generateStencilBuffer?: boolean;
  47077. /**
  47078. * Define if a depth texture is required instead of a depth buffer
  47079. */
  47080. generateDepthTexture?: boolean;
  47081. /**
  47082. * Define the number of desired draw buffers
  47083. */
  47084. textureCount?: number;
  47085. /**
  47086. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47087. */
  47088. doNotChangeAspectRatio?: boolean;
  47089. /**
  47090. * Define the default type of the buffers we are creating
  47091. */
  47092. defaultType?: number;
  47093. }
  47094. /**
  47095. * A multi render target, like a render target provides the ability to render to a texture.
  47096. * Unlike the render target, it can render to several draw buffers in one draw.
  47097. * This is specially interesting in deferred rendering or for any effects requiring more than
  47098. * just one color from a single pass.
  47099. */
  47100. export class MultiRenderTarget extends RenderTargetTexture {
  47101. private _internalTextures;
  47102. private _textures;
  47103. private _multiRenderTargetOptions;
  47104. /**
  47105. * Get if draw buffers are currently supported by the used hardware and browser.
  47106. */
  47107. get isSupported(): boolean;
  47108. /**
  47109. * Get the list of textures generated by the multi render target.
  47110. */
  47111. get textures(): Texture[];
  47112. /**
  47113. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47114. */
  47115. get depthTexture(): Texture;
  47116. /**
  47117. * Set the wrapping mode on U of all the textures we are rendering to.
  47118. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47119. */
  47120. set wrapU(wrap: number);
  47121. /**
  47122. * Set the wrapping mode on V of all the textures we are rendering to.
  47123. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47124. */
  47125. set wrapV(wrap: number);
  47126. /**
  47127. * Instantiate a new multi render target texture.
  47128. * A multi render target, like a render target provides the ability to render to a texture.
  47129. * Unlike the render target, it can render to several draw buffers in one draw.
  47130. * This is specially interesting in deferred rendering or for any effects requiring more than
  47131. * just one color from a single pass.
  47132. * @param name Define the name of the texture
  47133. * @param size Define the size of the buffers to render to
  47134. * @param count Define the number of target we are rendering into
  47135. * @param scene Define the scene the texture belongs to
  47136. * @param options Define the options used to create the multi render target
  47137. */
  47138. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47139. /** @hidden */
  47140. _rebuild(): void;
  47141. private _createInternalTextures;
  47142. private _createTextures;
  47143. /**
  47144. * Define the number of samples used if MSAA is enabled.
  47145. */
  47146. get samples(): number;
  47147. set samples(value: number);
  47148. /**
  47149. * Resize all the textures in the multi render target.
  47150. * Be carrefull as it will recreate all the data in the new texture.
  47151. * @param size Define the new size
  47152. */
  47153. resize(size: any): void;
  47154. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47155. /**
  47156. * Dispose the render targets and their associated resources
  47157. */
  47158. dispose(): void;
  47159. /**
  47160. * Release all the underlying texture used as draw buffers.
  47161. */
  47162. releaseInternalTextures(): void;
  47163. }
  47164. }
  47165. declare module BABYLON {
  47166. interface ThinEngine {
  47167. /**
  47168. * Unbind a list of render target textures from the webGL context
  47169. * This is used only when drawBuffer extension or webGL2 are active
  47170. * @param textures defines the render target textures to unbind
  47171. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47172. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47173. */
  47174. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47175. /**
  47176. * Create a multi render target texture
  47177. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47178. * @param size defines the size of the texture
  47179. * @param options defines the creation options
  47180. * @returns the cube texture as an InternalTexture
  47181. */
  47182. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47183. /**
  47184. * Update the sample count for a given multiple render target texture
  47185. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47186. * @param textures defines the textures to update
  47187. * @param samples defines the sample count to set
  47188. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47189. */
  47190. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47191. }
  47192. }
  47193. declare module BABYLON {
  47194. /**
  47195. * Class used to define an additional view for the engine
  47196. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47197. */
  47198. export class EngineView {
  47199. /** Defines the canvas where to render the view */
  47200. target: HTMLCanvasElement;
  47201. /** Defines an optional camera used to render the view (will use active camera else) */
  47202. camera?: Camera;
  47203. }
  47204. interface Engine {
  47205. /**
  47206. * Gets or sets the HTML element to use for attaching events
  47207. */
  47208. inputElement: Nullable<HTMLElement>;
  47209. /**
  47210. * Gets the current engine view
  47211. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47212. */
  47213. activeView: Nullable<EngineView>;
  47214. /** Gets or sets the list of views */
  47215. views: EngineView[];
  47216. /**
  47217. * Register a new child canvas
  47218. * @param canvas defines the canvas to register
  47219. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47220. * @returns the associated view
  47221. */
  47222. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47223. /**
  47224. * Remove a registered child canvas
  47225. * @param canvas defines the canvas to remove
  47226. * @returns the current engine
  47227. */
  47228. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47229. }
  47230. }
  47231. declare module BABYLON {
  47232. /**
  47233. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47234. */
  47235. export interface CubeMapInfo {
  47236. /**
  47237. * The pixel array for the front face.
  47238. * This is stored in format, left to right, up to down format.
  47239. */
  47240. front: Nullable<ArrayBufferView>;
  47241. /**
  47242. * The pixel array for the back face.
  47243. * This is stored in format, left to right, up to down format.
  47244. */
  47245. back: Nullable<ArrayBufferView>;
  47246. /**
  47247. * The pixel array for the left face.
  47248. * This is stored in format, left to right, up to down format.
  47249. */
  47250. left: Nullable<ArrayBufferView>;
  47251. /**
  47252. * The pixel array for the right face.
  47253. * This is stored in format, left to right, up to down format.
  47254. */
  47255. right: Nullable<ArrayBufferView>;
  47256. /**
  47257. * The pixel array for the up face.
  47258. * This is stored in format, left to right, up to down format.
  47259. */
  47260. up: Nullable<ArrayBufferView>;
  47261. /**
  47262. * The pixel array for the down face.
  47263. * This is stored in format, left to right, up to down format.
  47264. */
  47265. down: Nullable<ArrayBufferView>;
  47266. /**
  47267. * The size of the cubemap stored.
  47268. *
  47269. * Each faces will be size * size pixels.
  47270. */
  47271. size: number;
  47272. /**
  47273. * The format of the texture.
  47274. *
  47275. * RGBA, RGB.
  47276. */
  47277. format: number;
  47278. /**
  47279. * The type of the texture data.
  47280. *
  47281. * UNSIGNED_INT, FLOAT.
  47282. */
  47283. type: number;
  47284. /**
  47285. * Specifies whether the texture is in gamma space.
  47286. */
  47287. gammaSpace: boolean;
  47288. }
  47289. /**
  47290. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47291. */
  47292. export class PanoramaToCubeMapTools {
  47293. private static FACE_FRONT;
  47294. private static FACE_BACK;
  47295. private static FACE_RIGHT;
  47296. private static FACE_LEFT;
  47297. private static FACE_DOWN;
  47298. private static FACE_UP;
  47299. /**
  47300. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47301. *
  47302. * @param float32Array The source data.
  47303. * @param inputWidth The width of the input panorama.
  47304. * @param inputHeight The height of the input panorama.
  47305. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47306. * @return The cubemap data
  47307. */
  47308. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47309. private static CreateCubemapTexture;
  47310. private static CalcProjectionSpherical;
  47311. }
  47312. }
  47313. declare module BABYLON {
  47314. /**
  47315. * Helper class dealing with the extraction of spherical polynomial dataArray
  47316. * from a cube map.
  47317. */
  47318. export class CubeMapToSphericalPolynomialTools {
  47319. private static FileFaces;
  47320. /**
  47321. * Converts a texture to the according Spherical Polynomial data.
  47322. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47323. *
  47324. * @param texture The texture to extract the information from.
  47325. * @return The Spherical Polynomial data.
  47326. */
  47327. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47328. /**
  47329. * Converts a cubemap to the according Spherical Polynomial data.
  47330. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47331. *
  47332. * @param cubeInfo The Cube map to extract the information from.
  47333. * @return The Spherical Polynomial data.
  47334. */
  47335. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47336. }
  47337. }
  47338. declare module BABYLON {
  47339. interface BaseTexture {
  47340. /**
  47341. * Get the polynomial representation of the texture data.
  47342. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47343. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47344. */
  47345. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47346. }
  47347. }
  47348. declare module BABYLON {
  47349. /** @hidden */
  47350. export var rgbdEncodePixelShader: {
  47351. name: string;
  47352. shader: string;
  47353. };
  47354. }
  47355. declare module BABYLON {
  47356. /** @hidden */
  47357. export var rgbdDecodePixelShader: {
  47358. name: string;
  47359. shader: string;
  47360. };
  47361. }
  47362. declare module BABYLON {
  47363. /**
  47364. * Raw texture data and descriptor sufficient for WebGL texture upload
  47365. */
  47366. export interface EnvironmentTextureInfo {
  47367. /**
  47368. * Version of the environment map
  47369. */
  47370. version: number;
  47371. /**
  47372. * Width of image
  47373. */
  47374. width: number;
  47375. /**
  47376. * Irradiance information stored in the file.
  47377. */
  47378. irradiance: any;
  47379. /**
  47380. * Specular information stored in the file.
  47381. */
  47382. specular: any;
  47383. }
  47384. /**
  47385. * Defines One Image in the file. It requires only the position in the file
  47386. * as well as the length.
  47387. */
  47388. interface BufferImageData {
  47389. /**
  47390. * Length of the image data.
  47391. */
  47392. length: number;
  47393. /**
  47394. * Position of the data from the null terminator delimiting the end of the JSON.
  47395. */
  47396. position: number;
  47397. }
  47398. /**
  47399. * Defines the specular data enclosed in the file.
  47400. * This corresponds to the version 1 of the data.
  47401. */
  47402. export interface EnvironmentTextureSpecularInfoV1 {
  47403. /**
  47404. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47405. */
  47406. specularDataPosition?: number;
  47407. /**
  47408. * This contains all the images data needed to reconstruct the cubemap.
  47409. */
  47410. mipmaps: Array<BufferImageData>;
  47411. /**
  47412. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47413. */
  47414. lodGenerationScale: number;
  47415. }
  47416. /**
  47417. * Sets of helpers addressing the serialization and deserialization of environment texture
  47418. * stored in a BabylonJS env file.
  47419. * Those files are usually stored as .env files.
  47420. */
  47421. export class EnvironmentTextureTools {
  47422. /**
  47423. * Magic number identifying the env file.
  47424. */
  47425. private static _MagicBytes;
  47426. /**
  47427. * Gets the environment info from an env file.
  47428. * @param data The array buffer containing the .env bytes.
  47429. * @returns the environment file info (the json header) if successfully parsed.
  47430. */
  47431. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47432. /**
  47433. * Creates an environment texture from a loaded cube texture.
  47434. * @param texture defines the cube texture to convert in env file
  47435. * @return a promise containing the environment data if succesfull.
  47436. */
  47437. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47438. /**
  47439. * Creates a JSON representation of the spherical data.
  47440. * @param texture defines the texture containing the polynomials
  47441. * @return the JSON representation of the spherical info
  47442. */
  47443. private static _CreateEnvTextureIrradiance;
  47444. /**
  47445. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47446. * @param data the image data
  47447. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47448. * @return the views described by info providing access to the underlying buffer
  47449. */
  47450. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47451. /**
  47452. * Uploads the texture info contained in the env file to the GPU.
  47453. * @param texture defines the internal texture to upload to
  47454. * @param data defines the data to load
  47455. * @param info defines the texture info retrieved through the GetEnvInfo method
  47456. * @returns a promise
  47457. */
  47458. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47459. private static _OnImageReadyAsync;
  47460. /**
  47461. * Uploads the levels of image data to the GPU.
  47462. * @param texture defines the internal texture to upload to
  47463. * @param imageData defines the array buffer views of image data [mipmap][face]
  47464. * @returns a promise
  47465. */
  47466. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47467. /**
  47468. * Uploads spherical polynomials information to the texture.
  47469. * @param texture defines the texture we are trying to upload the information to
  47470. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47471. */
  47472. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47473. /** @hidden */
  47474. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47475. }
  47476. }
  47477. declare module BABYLON {
  47478. /**
  47479. * Contains position and normal vectors for a vertex
  47480. */
  47481. export class PositionNormalVertex {
  47482. /** the position of the vertex (defaut: 0,0,0) */
  47483. position: Vector3;
  47484. /** the normal of the vertex (defaut: 0,1,0) */
  47485. normal: Vector3;
  47486. /**
  47487. * Creates a PositionNormalVertex
  47488. * @param position the position of the vertex (defaut: 0,0,0)
  47489. * @param normal the normal of the vertex (defaut: 0,1,0)
  47490. */
  47491. constructor(
  47492. /** the position of the vertex (defaut: 0,0,0) */
  47493. position?: Vector3,
  47494. /** the normal of the vertex (defaut: 0,1,0) */
  47495. normal?: Vector3);
  47496. /**
  47497. * Clones the PositionNormalVertex
  47498. * @returns the cloned PositionNormalVertex
  47499. */
  47500. clone(): PositionNormalVertex;
  47501. }
  47502. /**
  47503. * Contains position, normal and uv vectors for a vertex
  47504. */
  47505. export class PositionNormalTextureVertex {
  47506. /** the position of the vertex (defaut: 0,0,0) */
  47507. position: Vector3;
  47508. /** the normal of the vertex (defaut: 0,1,0) */
  47509. normal: Vector3;
  47510. /** the uv of the vertex (default: 0,0) */
  47511. uv: Vector2;
  47512. /**
  47513. * Creates a PositionNormalTextureVertex
  47514. * @param position the position of the vertex (defaut: 0,0,0)
  47515. * @param normal the normal of the vertex (defaut: 0,1,0)
  47516. * @param uv the uv of the vertex (default: 0,0)
  47517. */
  47518. constructor(
  47519. /** the position of the vertex (defaut: 0,0,0) */
  47520. position?: Vector3,
  47521. /** the normal of the vertex (defaut: 0,1,0) */
  47522. normal?: Vector3,
  47523. /** the uv of the vertex (default: 0,0) */
  47524. uv?: Vector2);
  47525. /**
  47526. * Clones the PositionNormalTextureVertex
  47527. * @returns the cloned PositionNormalTextureVertex
  47528. */
  47529. clone(): PositionNormalTextureVertex;
  47530. }
  47531. }
  47532. declare module BABYLON {
  47533. /** @hidden */
  47534. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47535. private _genericAttributeLocation;
  47536. private _varyingLocationCount;
  47537. private _varyingLocationMap;
  47538. private _replacements;
  47539. private _textureCount;
  47540. private _uniforms;
  47541. lineProcessor(line: string): string;
  47542. attributeProcessor(attribute: string): string;
  47543. varyingProcessor(varying: string, isFragment: boolean): string;
  47544. uniformProcessor(uniform: string): string;
  47545. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47546. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47547. }
  47548. }
  47549. declare module BABYLON {
  47550. /**
  47551. * Container for accessors for natively-stored mesh data buffers.
  47552. */
  47553. class NativeDataBuffer extends DataBuffer {
  47554. /**
  47555. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47556. */
  47557. nativeIndexBuffer?: any;
  47558. /**
  47559. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47560. */
  47561. nativeVertexBuffer?: any;
  47562. }
  47563. /** @hidden */
  47564. class NativeTexture extends InternalTexture {
  47565. getInternalTexture(): InternalTexture;
  47566. getViewCount(): number;
  47567. }
  47568. /** @hidden */
  47569. export class NativeEngine extends Engine {
  47570. private readonly _native;
  47571. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47572. private readonly INVALID_HANDLE;
  47573. getHardwareScalingLevel(): number;
  47574. constructor();
  47575. /**
  47576. * Can be used to override the current requestAnimationFrame requester.
  47577. * @hidden
  47578. */
  47579. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47580. /**
  47581. * Override default engine behavior.
  47582. * @param color
  47583. * @param backBuffer
  47584. * @param depth
  47585. * @param stencil
  47586. */
  47587. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47588. /**
  47589. * Gets host document
  47590. * @returns the host document object
  47591. */
  47592. getHostDocument(): Nullable<Document>;
  47593. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47594. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47595. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47596. recordVertexArrayObject(vertexBuffers: {
  47597. [key: string]: VertexBuffer;
  47598. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47599. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47600. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47601. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47602. /**
  47603. * Draw a list of indexed primitives
  47604. * @param fillMode defines the primitive to use
  47605. * @param indexStart defines the starting index
  47606. * @param indexCount defines the number of index to draw
  47607. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47608. */
  47609. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47610. /**
  47611. * Draw a list of unindexed primitives
  47612. * @param fillMode defines the primitive to use
  47613. * @param verticesStart defines the index of first vertex to draw
  47614. * @param verticesCount defines the count of vertices to draw
  47615. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47616. */
  47617. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47618. createPipelineContext(): IPipelineContext;
  47619. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47620. /** @hidden */
  47621. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47622. /** @hidden */
  47623. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47624. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47625. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47626. protected _setProgram(program: WebGLProgram): void;
  47627. _releaseEffect(effect: Effect): void;
  47628. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47629. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47630. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47631. bindSamplers(effect: Effect): void;
  47632. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47633. getRenderWidth(useScreen?: boolean): number;
  47634. getRenderHeight(useScreen?: boolean): number;
  47635. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47636. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47637. /**
  47638. * Set the z offset to apply to current rendering
  47639. * @param value defines the offset to apply
  47640. */
  47641. setZOffset(value: number): void;
  47642. /**
  47643. * Gets the current value of the zOffset
  47644. * @returns the current zOffset state
  47645. */
  47646. getZOffset(): number;
  47647. /**
  47648. * Enable or disable depth buffering
  47649. * @param enable defines the state to set
  47650. */
  47651. setDepthBuffer(enable: boolean): void;
  47652. /**
  47653. * Gets a boolean indicating if depth writing is enabled
  47654. * @returns the current depth writing state
  47655. */
  47656. getDepthWrite(): boolean;
  47657. /**
  47658. * Enable or disable depth writing
  47659. * @param enable defines the state to set
  47660. */
  47661. setDepthWrite(enable: boolean): void;
  47662. /**
  47663. * Enable or disable color writing
  47664. * @param enable defines the state to set
  47665. */
  47666. setColorWrite(enable: boolean): void;
  47667. /**
  47668. * Gets a boolean indicating if color writing is enabled
  47669. * @returns the current color writing state
  47670. */
  47671. getColorWrite(): boolean;
  47672. /**
  47673. * Sets alpha constants used by some alpha blending modes
  47674. * @param r defines the red component
  47675. * @param g defines the green component
  47676. * @param b defines the blue component
  47677. * @param a defines the alpha component
  47678. */
  47679. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47680. /**
  47681. * Sets the current alpha mode
  47682. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47683. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47684. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47685. */
  47686. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47687. /**
  47688. * Gets the current alpha mode
  47689. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47690. * @returns the current alpha mode
  47691. */
  47692. getAlphaMode(): number;
  47693. setInt(uniform: WebGLUniformLocation, int: number): void;
  47694. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47695. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47696. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47697. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47698. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47699. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47700. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47701. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47702. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47703. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47704. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47705. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47706. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47707. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47708. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47709. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47710. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47711. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47712. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47713. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47714. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47715. wipeCaches(bruteForce?: boolean): void;
  47716. _createTexture(): WebGLTexture;
  47717. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47718. /**
  47719. * Usually called from BABYLON.Texture.ts.
  47720. * Passed information to create a WebGLTexture
  47721. * @param urlArg defines a value which contains one of the following:
  47722. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47723. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47724. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47725. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47726. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47727. * @param scene needed for loading to the correct scene
  47728. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47729. * @param onLoad optional callback to be called upon successful completion
  47730. * @param onError optional callback to be called upon failure
  47731. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47732. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47733. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47734. * @param forcedExtension defines the extension to use to pick the right loader
  47735. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47736. */
  47737. 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;
  47738. /**
  47739. * Creates a cube texture
  47740. * @param rootUrl defines the url where the files to load is located
  47741. * @param scene defines the current scene
  47742. * @param files defines the list of files to load (1 per face)
  47743. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47744. * @param onLoad defines an optional callback raised when the texture is loaded
  47745. * @param onError defines an optional callback raised if there is an issue to load the texture
  47746. * @param format defines the format of the data
  47747. * @param forcedExtension defines the extension to use to pick the right loader
  47748. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47749. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47750. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47751. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47752. * @returns the cube texture as an InternalTexture
  47753. */
  47754. 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;
  47755. private _getSamplingFilter;
  47756. private static _GetNativeTextureFormat;
  47757. createRenderTargetTexture(size: number | {
  47758. width: number;
  47759. height: number;
  47760. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47761. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47762. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47763. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47764. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47765. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47766. /**
  47767. * Updates a dynamic vertex buffer.
  47768. * @param vertexBuffer the vertex buffer to update
  47769. * @param data the data used to update the vertex buffer
  47770. * @param byteOffset the byte offset of the data (optional)
  47771. * @param byteLength the byte length of the data (optional)
  47772. */
  47773. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47774. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47775. private _updateAnisotropicLevel;
  47776. private _getAddressMode;
  47777. /** @hidden */
  47778. _bindTexture(channel: number, texture: InternalTexture): void;
  47779. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47780. releaseEffects(): void;
  47781. /** @hidden */
  47782. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47783. /** @hidden */
  47784. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47785. /** @hidden */
  47786. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47787. /** @hidden */
  47788. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47789. }
  47790. }
  47791. declare module BABYLON {
  47792. /**
  47793. * Gather the list of clipboard event types as constants.
  47794. */
  47795. export class ClipboardEventTypes {
  47796. /**
  47797. * The clipboard event is fired when a copy command is active (pressed).
  47798. */
  47799. static readonly COPY: number;
  47800. /**
  47801. * The clipboard event is fired when a cut command is active (pressed).
  47802. */
  47803. static readonly CUT: number;
  47804. /**
  47805. * The clipboard event is fired when a paste command is active (pressed).
  47806. */
  47807. static readonly PASTE: number;
  47808. }
  47809. /**
  47810. * This class is used to store clipboard related info for the onClipboardObservable event.
  47811. */
  47812. export class ClipboardInfo {
  47813. /**
  47814. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47815. */
  47816. type: number;
  47817. /**
  47818. * Defines the related dom event
  47819. */
  47820. event: ClipboardEvent;
  47821. /**
  47822. *Creates an instance of ClipboardInfo.
  47823. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47824. * @param event Defines the related dom event
  47825. */
  47826. constructor(
  47827. /**
  47828. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47829. */
  47830. type: number,
  47831. /**
  47832. * Defines the related dom event
  47833. */
  47834. event: ClipboardEvent);
  47835. /**
  47836. * Get the clipboard event's type from the keycode.
  47837. * @param keyCode Defines the keyCode for the current keyboard event.
  47838. * @return {number}
  47839. */
  47840. static GetTypeFromCharacter(keyCode: number): number;
  47841. }
  47842. }
  47843. declare module BABYLON {
  47844. /**
  47845. * Google Daydream controller
  47846. */
  47847. export class DaydreamController extends WebVRController {
  47848. /**
  47849. * Base Url for the controller model.
  47850. */
  47851. static MODEL_BASE_URL: string;
  47852. /**
  47853. * File name for the controller model.
  47854. */
  47855. static MODEL_FILENAME: string;
  47856. /**
  47857. * Gamepad Id prefix used to identify Daydream Controller.
  47858. */
  47859. static readonly GAMEPAD_ID_PREFIX: string;
  47860. /**
  47861. * Creates a new DaydreamController from a gamepad
  47862. * @param vrGamepad the gamepad that the controller should be created from
  47863. */
  47864. constructor(vrGamepad: any);
  47865. /**
  47866. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47867. * @param scene scene in which to add meshes
  47868. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47869. */
  47870. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47871. /**
  47872. * Called once for each button that changed state since the last frame
  47873. * @param buttonIdx Which button index changed
  47874. * @param state New state of the button
  47875. * @param changes Which properties on the state changed since last frame
  47876. */
  47877. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47878. }
  47879. }
  47880. declare module BABYLON {
  47881. /**
  47882. * Gear VR Controller
  47883. */
  47884. export class GearVRController extends WebVRController {
  47885. /**
  47886. * Base Url for the controller model.
  47887. */
  47888. static MODEL_BASE_URL: string;
  47889. /**
  47890. * File name for the controller model.
  47891. */
  47892. static MODEL_FILENAME: string;
  47893. /**
  47894. * Gamepad Id prefix used to identify this controller.
  47895. */
  47896. static readonly GAMEPAD_ID_PREFIX: string;
  47897. private readonly _buttonIndexToObservableNameMap;
  47898. /**
  47899. * Creates a new GearVRController from a gamepad
  47900. * @param vrGamepad the gamepad that the controller should be created from
  47901. */
  47902. constructor(vrGamepad: any);
  47903. /**
  47904. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47905. * @param scene scene in which to add meshes
  47906. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47907. */
  47908. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47909. /**
  47910. * Called once for each button that changed state since the last frame
  47911. * @param buttonIdx Which button index changed
  47912. * @param state New state of the button
  47913. * @param changes Which properties on the state changed since last frame
  47914. */
  47915. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47916. }
  47917. }
  47918. declare module BABYLON {
  47919. /**
  47920. * Generic Controller
  47921. */
  47922. export class GenericController extends WebVRController {
  47923. /**
  47924. * Base Url for the controller model.
  47925. */
  47926. static readonly MODEL_BASE_URL: string;
  47927. /**
  47928. * File name for the controller model.
  47929. */
  47930. static readonly MODEL_FILENAME: string;
  47931. /**
  47932. * Creates a new GenericController from a gamepad
  47933. * @param vrGamepad the gamepad that the controller should be created from
  47934. */
  47935. constructor(vrGamepad: any);
  47936. /**
  47937. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47938. * @param scene scene in which to add meshes
  47939. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47940. */
  47941. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47942. /**
  47943. * Called once for each button that changed state since the last frame
  47944. * @param buttonIdx Which button index changed
  47945. * @param state New state of the button
  47946. * @param changes Which properties on the state changed since last frame
  47947. */
  47948. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47949. }
  47950. }
  47951. declare module BABYLON {
  47952. /**
  47953. * Oculus Touch Controller
  47954. */
  47955. export class OculusTouchController extends WebVRController {
  47956. /**
  47957. * Base Url for the controller model.
  47958. */
  47959. static MODEL_BASE_URL: string;
  47960. /**
  47961. * File name for the left controller model.
  47962. */
  47963. static MODEL_LEFT_FILENAME: string;
  47964. /**
  47965. * File name for the right controller model.
  47966. */
  47967. static MODEL_RIGHT_FILENAME: string;
  47968. /**
  47969. * Base Url for the Quest controller model.
  47970. */
  47971. static QUEST_MODEL_BASE_URL: string;
  47972. /**
  47973. * @hidden
  47974. * If the controllers are running on a device that needs the updated Quest controller models
  47975. */
  47976. static _IsQuest: boolean;
  47977. /**
  47978. * Fired when the secondary trigger on this controller is modified
  47979. */
  47980. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47981. /**
  47982. * Fired when the thumb rest on this controller is modified
  47983. */
  47984. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47985. /**
  47986. * Creates a new OculusTouchController from a gamepad
  47987. * @param vrGamepad the gamepad that the controller should be created from
  47988. */
  47989. constructor(vrGamepad: any);
  47990. /**
  47991. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47992. * @param scene scene in which to add meshes
  47993. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47994. */
  47995. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47996. /**
  47997. * Fired when the A button on this controller is modified
  47998. */
  47999. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48000. /**
  48001. * Fired when the B button on this controller is modified
  48002. */
  48003. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48004. /**
  48005. * Fired when the X button on this controller is modified
  48006. */
  48007. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48008. /**
  48009. * Fired when the Y button on this controller is modified
  48010. */
  48011. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48012. /**
  48013. * Called once for each button that changed state since the last frame
  48014. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48015. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48016. * 2) secondary trigger (same)
  48017. * 3) A (right) X (left), touch, pressed = value
  48018. * 4) B / Y
  48019. * 5) thumb rest
  48020. * @param buttonIdx Which button index changed
  48021. * @param state New state of the button
  48022. * @param changes Which properties on the state changed since last frame
  48023. */
  48024. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48025. }
  48026. }
  48027. declare module BABYLON {
  48028. /**
  48029. * Vive Controller
  48030. */
  48031. export class ViveController extends WebVRController {
  48032. /**
  48033. * Base Url for the controller model.
  48034. */
  48035. static MODEL_BASE_URL: string;
  48036. /**
  48037. * File name for the controller model.
  48038. */
  48039. static MODEL_FILENAME: string;
  48040. /**
  48041. * Creates a new ViveController from a gamepad
  48042. * @param vrGamepad the gamepad that the controller should be created from
  48043. */
  48044. constructor(vrGamepad: any);
  48045. /**
  48046. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48047. * @param scene scene in which to add meshes
  48048. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48049. */
  48050. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48051. /**
  48052. * Fired when the left button on this controller is modified
  48053. */
  48054. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48055. /**
  48056. * Fired when the right button on this controller is modified
  48057. */
  48058. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48059. /**
  48060. * Fired when the menu button on this controller is modified
  48061. */
  48062. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48063. /**
  48064. * Called once for each button that changed state since the last frame
  48065. * Vive mapping:
  48066. * 0: touchpad
  48067. * 1: trigger
  48068. * 2: left AND right buttons
  48069. * 3: menu button
  48070. * @param buttonIdx Which button index changed
  48071. * @param state New state of the button
  48072. * @param changes Which properties on the state changed since last frame
  48073. */
  48074. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48075. }
  48076. }
  48077. declare module BABYLON {
  48078. /**
  48079. * Defines the WindowsMotionController object that the state of the windows motion controller
  48080. */
  48081. export class WindowsMotionController extends WebVRController {
  48082. /**
  48083. * The base url used to load the left and right controller models
  48084. */
  48085. static MODEL_BASE_URL: string;
  48086. /**
  48087. * The name of the left controller model file
  48088. */
  48089. static MODEL_LEFT_FILENAME: string;
  48090. /**
  48091. * The name of the right controller model file
  48092. */
  48093. static MODEL_RIGHT_FILENAME: string;
  48094. /**
  48095. * The controller name prefix for this controller type
  48096. */
  48097. static readonly GAMEPAD_ID_PREFIX: string;
  48098. /**
  48099. * The controller id pattern for this controller type
  48100. */
  48101. private static readonly GAMEPAD_ID_PATTERN;
  48102. private _loadedMeshInfo;
  48103. protected readonly _mapping: {
  48104. buttons: string[];
  48105. buttonMeshNames: {
  48106. 'trigger': string;
  48107. 'menu': string;
  48108. 'grip': string;
  48109. 'thumbstick': string;
  48110. 'trackpad': string;
  48111. };
  48112. buttonObservableNames: {
  48113. 'trigger': string;
  48114. 'menu': string;
  48115. 'grip': string;
  48116. 'thumbstick': string;
  48117. 'trackpad': string;
  48118. };
  48119. axisMeshNames: string[];
  48120. pointingPoseMeshName: string;
  48121. };
  48122. /**
  48123. * Fired when the trackpad on this controller is clicked
  48124. */
  48125. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48126. /**
  48127. * Fired when the trackpad on this controller is modified
  48128. */
  48129. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48130. /**
  48131. * The current x and y values of this controller's trackpad
  48132. */
  48133. trackpad: StickValues;
  48134. /**
  48135. * Creates a new WindowsMotionController from a gamepad
  48136. * @param vrGamepad the gamepad that the controller should be created from
  48137. */
  48138. constructor(vrGamepad: any);
  48139. /**
  48140. * Fired when the trigger on this controller is modified
  48141. */
  48142. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48143. /**
  48144. * Fired when the menu button on this controller is modified
  48145. */
  48146. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48147. /**
  48148. * Fired when the grip button on this controller is modified
  48149. */
  48150. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48151. /**
  48152. * Fired when the thumbstick button on this controller is modified
  48153. */
  48154. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48155. /**
  48156. * Fired when the touchpad button on this controller is modified
  48157. */
  48158. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48159. /**
  48160. * Fired when the touchpad values on this controller are modified
  48161. */
  48162. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48163. protected _updateTrackpad(): void;
  48164. /**
  48165. * Called once per frame by the engine.
  48166. */
  48167. update(): void;
  48168. /**
  48169. * Called once for each button that changed state since the last frame
  48170. * @param buttonIdx Which button index changed
  48171. * @param state New state of the button
  48172. * @param changes Which properties on the state changed since last frame
  48173. */
  48174. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48175. /**
  48176. * Moves the buttons on the controller mesh based on their current state
  48177. * @param buttonName the name of the button to move
  48178. * @param buttonValue the value of the button which determines the buttons new position
  48179. */
  48180. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48181. /**
  48182. * Moves the axis on the controller mesh based on its current state
  48183. * @param axis the index of the axis
  48184. * @param axisValue the value of the axis which determines the meshes new position
  48185. * @hidden
  48186. */
  48187. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48188. /**
  48189. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48190. * @param scene scene in which to add meshes
  48191. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48192. */
  48193. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48194. /**
  48195. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48196. * can be transformed by button presses and axes values, based on this._mapping.
  48197. *
  48198. * @param scene scene in which the meshes exist
  48199. * @param meshes list of meshes that make up the controller model to process
  48200. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48201. */
  48202. private processModel;
  48203. private createMeshInfo;
  48204. /**
  48205. * Gets the ray of the controller in the direction the controller is pointing
  48206. * @param length the length the resulting ray should be
  48207. * @returns a ray in the direction the controller is pointing
  48208. */
  48209. getForwardRay(length?: number): Ray;
  48210. /**
  48211. * Disposes of the controller
  48212. */
  48213. dispose(): void;
  48214. }
  48215. /**
  48216. * This class represents a new windows motion controller in XR.
  48217. */
  48218. export class XRWindowsMotionController extends WindowsMotionController {
  48219. /**
  48220. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48221. */
  48222. protected readonly _mapping: {
  48223. buttons: string[];
  48224. buttonMeshNames: {
  48225. 'trigger': string;
  48226. 'menu': string;
  48227. 'grip': string;
  48228. 'thumbstick': string;
  48229. 'trackpad': string;
  48230. };
  48231. buttonObservableNames: {
  48232. 'trigger': string;
  48233. 'menu': string;
  48234. 'grip': string;
  48235. 'thumbstick': string;
  48236. 'trackpad': string;
  48237. };
  48238. axisMeshNames: string[];
  48239. pointingPoseMeshName: string;
  48240. };
  48241. /**
  48242. * Construct a new XR-Based windows motion controller
  48243. *
  48244. * @param gamepadInfo the gamepad object from the browser
  48245. */
  48246. constructor(gamepadInfo: any);
  48247. /**
  48248. * holds the thumbstick values (X,Y)
  48249. */
  48250. thumbstickValues: StickValues;
  48251. /**
  48252. * Fired when the thumbstick on this controller is clicked
  48253. */
  48254. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48255. /**
  48256. * Fired when the thumbstick on this controller is modified
  48257. */
  48258. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48259. /**
  48260. * Fired when the touchpad button on this controller is modified
  48261. */
  48262. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48263. /**
  48264. * Fired when the touchpad values on this controller are modified
  48265. */
  48266. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48267. /**
  48268. * Fired when the thumbstick button on this controller is modified
  48269. * here to prevent breaking changes
  48270. */
  48271. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48272. /**
  48273. * updating the thumbstick(!) and not the trackpad.
  48274. * This is named this way due to the difference between WebVR and XR and to avoid
  48275. * changing the parent class.
  48276. */
  48277. protected _updateTrackpad(): void;
  48278. /**
  48279. * Disposes the class with joy
  48280. */
  48281. dispose(): void;
  48282. }
  48283. }
  48284. declare module BABYLON {
  48285. /**
  48286. * Class containing static functions to help procedurally build meshes
  48287. */
  48288. export class PolyhedronBuilder {
  48289. /**
  48290. * Creates a polyhedron mesh
  48291. * * 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
  48292. * * The parameter `size` (positive float, default 1) sets the polygon size
  48293. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48294. * * 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`
  48295. * * 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
  48296. * * 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)`)
  48297. * * 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
  48298. * * 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
  48299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48300. * * 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
  48301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48302. * @param name defines the name of the mesh
  48303. * @param options defines the options used to create the mesh
  48304. * @param scene defines the hosting scene
  48305. * @returns the polyhedron mesh
  48306. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48307. */
  48308. static CreatePolyhedron(name: string, options: {
  48309. type?: number;
  48310. size?: number;
  48311. sizeX?: number;
  48312. sizeY?: number;
  48313. sizeZ?: number;
  48314. custom?: any;
  48315. faceUV?: Vector4[];
  48316. faceColors?: Color4[];
  48317. flat?: boolean;
  48318. updatable?: boolean;
  48319. sideOrientation?: number;
  48320. frontUVs?: Vector4;
  48321. backUVs?: Vector4;
  48322. }, scene?: Nullable<Scene>): Mesh;
  48323. }
  48324. }
  48325. declare module BABYLON {
  48326. /**
  48327. * Gizmo that enables scaling a mesh along 3 axis
  48328. */
  48329. export class ScaleGizmo extends Gizmo {
  48330. /**
  48331. * Internal gizmo used for interactions on the x axis
  48332. */
  48333. xGizmo: AxisScaleGizmo;
  48334. /**
  48335. * Internal gizmo used for interactions on the y axis
  48336. */
  48337. yGizmo: AxisScaleGizmo;
  48338. /**
  48339. * Internal gizmo used for interactions on the z axis
  48340. */
  48341. zGizmo: AxisScaleGizmo;
  48342. /**
  48343. * Internal gizmo used to scale all axis equally
  48344. */
  48345. uniformScaleGizmo: AxisScaleGizmo;
  48346. private _meshAttached;
  48347. private _updateGizmoRotationToMatchAttachedMesh;
  48348. private _snapDistance;
  48349. private _scaleRatio;
  48350. private _uniformScalingMesh;
  48351. private _octahedron;
  48352. private _sensitivity;
  48353. /** Fires an event when any of it's sub gizmos are dragged */
  48354. onDragStartObservable: Observable<unknown>;
  48355. /** Fires an event when any of it's sub gizmos are released from dragging */
  48356. onDragEndObservable: Observable<unknown>;
  48357. get attachedMesh(): Nullable<AbstractMesh>;
  48358. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48359. /**
  48360. * Creates a ScaleGizmo
  48361. * @param gizmoLayer The utility layer the gizmo will be added to
  48362. */
  48363. constructor(gizmoLayer?: UtilityLayerRenderer);
  48364. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48365. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48366. /**
  48367. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48368. */
  48369. set snapDistance(value: number);
  48370. get snapDistance(): number;
  48371. /**
  48372. * Ratio for the scale of the gizmo (Default: 1)
  48373. */
  48374. set scaleRatio(value: number);
  48375. get scaleRatio(): number;
  48376. /**
  48377. * Sensitivity factor for dragging (Default: 1)
  48378. */
  48379. set sensitivity(value: number);
  48380. get sensitivity(): number;
  48381. /**
  48382. * Disposes of the gizmo
  48383. */
  48384. dispose(): void;
  48385. }
  48386. }
  48387. declare module BABYLON {
  48388. /**
  48389. * Single axis scale gizmo
  48390. */
  48391. export class AxisScaleGizmo extends Gizmo {
  48392. /**
  48393. * Drag behavior responsible for the gizmos dragging interactions
  48394. */
  48395. dragBehavior: PointerDragBehavior;
  48396. private _pointerObserver;
  48397. /**
  48398. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48399. */
  48400. snapDistance: number;
  48401. /**
  48402. * Event that fires each time the gizmo snaps to a new location.
  48403. * * snapDistance is the the change in distance
  48404. */
  48405. onSnapObservable: Observable<{
  48406. snapDistance: number;
  48407. }>;
  48408. /**
  48409. * If the scaling operation should be done on all axis (default: false)
  48410. */
  48411. uniformScaling: boolean;
  48412. /**
  48413. * Custom sensitivity value for the drag strength
  48414. */
  48415. sensitivity: number;
  48416. private _isEnabled;
  48417. private _parent;
  48418. private _arrow;
  48419. private _coloredMaterial;
  48420. private _hoverMaterial;
  48421. /**
  48422. * Creates an AxisScaleGizmo
  48423. * @param gizmoLayer The utility layer the gizmo will be added to
  48424. * @param dragAxis The axis which the gizmo will be able to scale on
  48425. * @param color The color of the gizmo
  48426. */
  48427. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48428. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48429. /**
  48430. * If the gizmo is enabled
  48431. */
  48432. set isEnabled(value: boolean);
  48433. get isEnabled(): boolean;
  48434. /**
  48435. * Disposes of the gizmo
  48436. */
  48437. dispose(): void;
  48438. /**
  48439. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48440. * @param mesh The mesh to replace the default mesh of the gizmo
  48441. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48442. */
  48443. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48444. }
  48445. }
  48446. declare module BABYLON {
  48447. /**
  48448. * Bounding box gizmo
  48449. */
  48450. export class BoundingBoxGizmo extends Gizmo {
  48451. private _lineBoundingBox;
  48452. private _rotateSpheresParent;
  48453. private _scaleBoxesParent;
  48454. private _boundingDimensions;
  48455. private _renderObserver;
  48456. private _pointerObserver;
  48457. private _scaleDragSpeed;
  48458. private _tmpQuaternion;
  48459. private _tmpVector;
  48460. private _tmpRotationMatrix;
  48461. /**
  48462. * 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)
  48463. */
  48464. ignoreChildren: boolean;
  48465. /**
  48466. * 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)
  48467. */
  48468. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48469. /**
  48470. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48471. */
  48472. rotationSphereSize: number;
  48473. /**
  48474. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48475. */
  48476. scaleBoxSize: number;
  48477. /**
  48478. * 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)
  48479. */
  48480. fixedDragMeshScreenSize: boolean;
  48481. /**
  48482. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48483. */
  48484. fixedDragMeshScreenSizeDistanceFactor: number;
  48485. /**
  48486. * Fired when a rotation sphere or scale box is dragged
  48487. */
  48488. onDragStartObservable: Observable<{}>;
  48489. /**
  48490. * Fired when a scale box is dragged
  48491. */
  48492. onScaleBoxDragObservable: Observable<{}>;
  48493. /**
  48494. * Fired when a scale box drag is ended
  48495. */
  48496. onScaleBoxDragEndObservable: Observable<{}>;
  48497. /**
  48498. * Fired when a rotation sphere is dragged
  48499. */
  48500. onRotationSphereDragObservable: Observable<{}>;
  48501. /**
  48502. * Fired when a rotation sphere drag is ended
  48503. */
  48504. onRotationSphereDragEndObservable: Observable<{}>;
  48505. /**
  48506. * 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)
  48507. */
  48508. scalePivot: Nullable<Vector3>;
  48509. /**
  48510. * Mesh used as a pivot to rotate the attached mesh
  48511. */
  48512. private _anchorMesh;
  48513. private _existingMeshScale;
  48514. private _dragMesh;
  48515. private pointerDragBehavior;
  48516. private coloredMaterial;
  48517. private hoverColoredMaterial;
  48518. /**
  48519. * Sets the color of the bounding box gizmo
  48520. * @param color the color to set
  48521. */
  48522. setColor(color: Color3): void;
  48523. /**
  48524. * Creates an BoundingBoxGizmo
  48525. * @param gizmoLayer The utility layer the gizmo will be added to
  48526. * @param color The color of the gizmo
  48527. */
  48528. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48530. private _selectNode;
  48531. /**
  48532. * Updates the bounding box information for the Gizmo
  48533. */
  48534. updateBoundingBox(): void;
  48535. private _updateRotationSpheres;
  48536. private _updateScaleBoxes;
  48537. /**
  48538. * Enables rotation on the specified axis and disables rotation on the others
  48539. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48540. */
  48541. setEnabledRotationAxis(axis: string): void;
  48542. /**
  48543. * Enables/disables scaling
  48544. * @param enable if scaling should be enabled
  48545. */
  48546. setEnabledScaling(enable: boolean): void;
  48547. private _updateDummy;
  48548. /**
  48549. * Enables a pointer drag behavior on the bounding box of the gizmo
  48550. */
  48551. enableDragBehavior(): void;
  48552. /**
  48553. * Disposes of the gizmo
  48554. */
  48555. dispose(): void;
  48556. /**
  48557. * 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)
  48558. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48559. * @returns the bounding box mesh with the passed in mesh as a child
  48560. */
  48561. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48562. /**
  48563. * CustomMeshes are not supported by this gizmo
  48564. * @param mesh The mesh to replace the default mesh of the gizmo
  48565. */
  48566. setCustomMesh(mesh: Mesh): void;
  48567. }
  48568. }
  48569. declare module BABYLON {
  48570. /**
  48571. * Single plane rotation gizmo
  48572. */
  48573. export class PlaneRotationGizmo extends Gizmo {
  48574. /**
  48575. * Drag behavior responsible for the gizmos dragging interactions
  48576. */
  48577. dragBehavior: PointerDragBehavior;
  48578. private _pointerObserver;
  48579. /**
  48580. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48581. */
  48582. snapDistance: number;
  48583. /**
  48584. * Event that fires each time the gizmo snaps to a new location.
  48585. * * snapDistance is the the change in distance
  48586. */
  48587. onSnapObservable: Observable<{
  48588. snapDistance: number;
  48589. }>;
  48590. private _isEnabled;
  48591. private _parent;
  48592. /**
  48593. * Creates a PlaneRotationGizmo
  48594. * @param gizmoLayer The utility layer the gizmo will be added to
  48595. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48596. * @param color The color of the gizmo
  48597. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48598. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48599. */
  48600. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48601. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48602. /**
  48603. * If the gizmo is enabled
  48604. */
  48605. set isEnabled(value: boolean);
  48606. get isEnabled(): boolean;
  48607. /**
  48608. * Disposes of the gizmo
  48609. */
  48610. dispose(): void;
  48611. }
  48612. }
  48613. declare module BABYLON {
  48614. /**
  48615. * Gizmo that enables rotating a mesh along 3 axis
  48616. */
  48617. export class RotationGizmo extends Gizmo {
  48618. /**
  48619. * Internal gizmo used for interactions on the x axis
  48620. */
  48621. xGizmo: PlaneRotationGizmo;
  48622. /**
  48623. * Internal gizmo used for interactions on the y axis
  48624. */
  48625. yGizmo: PlaneRotationGizmo;
  48626. /**
  48627. * Internal gizmo used for interactions on the z axis
  48628. */
  48629. zGizmo: PlaneRotationGizmo;
  48630. /** Fires an event when any of it's sub gizmos are dragged */
  48631. onDragStartObservable: Observable<unknown>;
  48632. /** Fires an event when any of it's sub gizmos are released from dragging */
  48633. onDragEndObservable: Observable<unknown>;
  48634. private _meshAttached;
  48635. get attachedMesh(): Nullable<AbstractMesh>;
  48636. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48637. /**
  48638. * Creates a RotationGizmo
  48639. * @param gizmoLayer The utility layer the gizmo will be added to
  48640. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48641. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48642. */
  48643. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48644. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48645. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48646. /**
  48647. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48648. */
  48649. set snapDistance(value: number);
  48650. get snapDistance(): number;
  48651. /**
  48652. * Ratio for the scale of the gizmo (Default: 1)
  48653. */
  48654. set scaleRatio(value: number);
  48655. get scaleRatio(): number;
  48656. /**
  48657. * Disposes of the gizmo
  48658. */
  48659. dispose(): void;
  48660. /**
  48661. * CustomMeshes are not supported by this gizmo
  48662. * @param mesh The mesh to replace the default mesh of the gizmo
  48663. */
  48664. setCustomMesh(mesh: Mesh): void;
  48665. }
  48666. }
  48667. declare module BABYLON {
  48668. /**
  48669. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48670. */
  48671. export class GizmoManager implements IDisposable {
  48672. private scene;
  48673. /**
  48674. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48675. */
  48676. gizmos: {
  48677. positionGizmo: Nullable<PositionGizmo>;
  48678. rotationGizmo: Nullable<RotationGizmo>;
  48679. scaleGizmo: Nullable<ScaleGizmo>;
  48680. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48681. };
  48682. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48683. clearGizmoOnEmptyPointerEvent: boolean;
  48684. /** Fires an event when the manager is attached to a mesh */
  48685. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48686. private _gizmosEnabled;
  48687. private _pointerObserver;
  48688. private _attachedMesh;
  48689. private _boundingBoxColor;
  48690. private _defaultUtilityLayer;
  48691. private _defaultKeepDepthUtilityLayer;
  48692. /**
  48693. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48694. */
  48695. boundingBoxDragBehavior: SixDofDragBehavior;
  48696. /**
  48697. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48698. */
  48699. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48700. /**
  48701. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48702. */
  48703. usePointerToAttachGizmos: boolean;
  48704. /**
  48705. * Utility layer that the bounding box gizmo belongs to
  48706. */
  48707. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48708. /**
  48709. * Utility layer that all gizmos besides bounding box belong to
  48710. */
  48711. get utilityLayer(): UtilityLayerRenderer;
  48712. /**
  48713. * Instatiates a gizmo manager
  48714. * @param scene the scene to overlay the gizmos on top of
  48715. */
  48716. constructor(scene: Scene);
  48717. /**
  48718. * Attaches a set of gizmos to the specified mesh
  48719. * @param mesh The mesh the gizmo's should be attached to
  48720. */
  48721. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48722. /**
  48723. * If the position gizmo is enabled
  48724. */
  48725. set positionGizmoEnabled(value: boolean);
  48726. get positionGizmoEnabled(): boolean;
  48727. /**
  48728. * If the rotation gizmo is enabled
  48729. */
  48730. set rotationGizmoEnabled(value: boolean);
  48731. get rotationGizmoEnabled(): boolean;
  48732. /**
  48733. * If the scale gizmo is enabled
  48734. */
  48735. set scaleGizmoEnabled(value: boolean);
  48736. get scaleGizmoEnabled(): boolean;
  48737. /**
  48738. * If the boundingBox gizmo is enabled
  48739. */
  48740. set boundingBoxGizmoEnabled(value: boolean);
  48741. get boundingBoxGizmoEnabled(): boolean;
  48742. /**
  48743. * Disposes of the gizmo manager
  48744. */
  48745. dispose(): void;
  48746. }
  48747. }
  48748. declare module BABYLON {
  48749. /**
  48750. * A directional light is defined by a direction (what a surprise!).
  48751. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48752. * 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.
  48753. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48754. */
  48755. export class DirectionalLight extends ShadowLight {
  48756. private _shadowFrustumSize;
  48757. /**
  48758. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48759. */
  48760. get shadowFrustumSize(): number;
  48761. /**
  48762. * Specifies a fix frustum size for the shadow generation.
  48763. */
  48764. set shadowFrustumSize(value: number);
  48765. private _shadowOrthoScale;
  48766. /**
  48767. * Gets the shadow projection scale against the optimal computed one.
  48768. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48769. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48770. */
  48771. get shadowOrthoScale(): number;
  48772. /**
  48773. * Sets the shadow projection scale against the optimal computed one.
  48774. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48775. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48776. */
  48777. set shadowOrthoScale(value: number);
  48778. /**
  48779. * Automatically compute the projection matrix to best fit (including all the casters)
  48780. * on each frame.
  48781. */
  48782. autoUpdateExtends: boolean;
  48783. /**
  48784. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48785. * on each frame. autoUpdateExtends must be set to true for this to work
  48786. */
  48787. autoCalcShadowZBounds: boolean;
  48788. private _orthoLeft;
  48789. private _orthoRight;
  48790. private _orthoTop;
  48791. private _orthoBottom;
  48792. /**
  48793. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48794. * The directional light is emitted from everywhere in the given direction.
  48795. * It can cast shadows.
  48796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48797. * @param name The friendly name of the light
  48798. * @param direction The direction of the light
  48799. * @param scene The scene the light belongs to
  48800. */
  48801. constructor(name: string, direction: Vector3, scene: Scene);
  48802. /**
  48803. * Returns the string "DirectionalLight".
  48804. * @return The class name
  48805. */
  48806. getClassName(): string;
  48807. /**
  48808. * Returns the integer 1.
  48809. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48810. */
  48811. getTypeID(): number;
  48812. /**
  48813. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48814. * Returns the DirectionalLight Shadow projection matrix.
  48815. */
  48816. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48817. /**
  48818. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48819. * Returns the DirectionalLight Shadow projection matrix.
  48820. */
  48821. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48822. /**
  48823. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48824. * Returns the DirectionalLight Shadow projection matrix.
  48825. */
  48826. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48827. protected _buildUniformLayout(): void;
  48828. /**
  48829. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48830. * @param effect The effect to update
  48831. * @param lightIndex The index of the light in the effect to update
  48832. * @returns The directional light
  48833. */
  48834. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48835. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48836. /**
  48837. * Gets the minZ used for shadow according to both the scene and the light.
  48838. *
  48839. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48840. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48841. * @param activeCamera The camera we are returning the min for
  48842. * @returns the depth min z
  48843. */
  48844. getDepthMinZ(activeCamera: Camera): number;
  48845. /**
  48846. * Gets the maxZ used for shadow according to both the scene and the light.
  48847. *
  48848. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48849. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48850. * @param activeCamera The camera we are returning the max for
  48851. * @returns the depth max z
  48852. */
  48853. getDepthMaxZ(activeCamera: Camera): number;
  48854. /**
  48855. * Prepares the list of defines specific to the light type.
  48856. * @param defines the list of defines
  48857. * @param lightIndex defines the index of the light for the effect
  48858. */
  48859. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48860. }
  48861. }
  48862. declare module BABYLON {
  48863. /**
  48864. * Class containing static functions to help procedurally build meshes
  48865. */
  48866. export class HemisphereBuilder {
  48867. /**
  48868. * Creates a hemisphere mesh
  48869. * @param name defines the name of the mesh
  48870. * @param options defines the options used to create the mesh
  48871. * @param scene defines the hosting scene
  48872. * @returns the hemisphere mesh
  48873. */
  48874. static CreateHemisphere(name: string, options: {
  48875. segments?: number;
  48876. diameter?: number;
  48877. sideOrientation?: number;
  48878. }, scene: any): Mesh;
  48879. }
  48880. }
  48881. declare module BABYLON {
  48882. /**
  48883. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48884. * These values define a cone of light starting from the position, emitting toward the direction.
  48885. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48886. * and the exponent defines the speed of the decay of the light with distance (reach).
  48887. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48888. */
  48889. export class SpotLight extends ShadowLight {
  48890. private _angle;
  48891. private _innerAngle;
  48892. private _cosHalfAngle;
  48893. private _lightAngleScale;
  48894. private _lightAngleOffset;
  48895. /**
  48896. * Gets the cone angle of the spot light in Radians.
  48897. */
  48898. get angle(): number;
  48899. /**
  48900. * Sets the cone angle of the spot light in Radians.
  48901. */
  48902. set angle(value: number);
  48903. /**
  48904. * Only used in gltf falloff mode, this defines the angle where
  48905. * the directional falloff will start before cutting at angle which could be seen
  48906. * as outer angle.
  48907. */
  48908. get innerAngle(): number;
  48909. /**
  48910. * Only used in gltf falloff mode, this defines the angle where
  48911. * the directional falloff will start before cutting at angle which could be seen
  48912. * as outer angle.
  48913. */
  48914. set innerAngle(value: number);
  48915. private _shadowAngleScale;
  48916. /**
  48917. * Allows scaling the angle of the light for shadow generation only.
  48918. */
  48919. get shadowAngleScale(): number;
  48920. /**
  48921. * Allows scaling the angle of the light for shadow generation only.
  48922. */
  48923. set shadowAngleScale(value: number);
  48924. /**
  48925. * The light decay speed with the distance from the emission spot.
  48926. */
  48927. exponent: number;
  48928. private _projectionTextureMatrix;
  48929. /**
  48930. * Allows reading the projecton texture
  48931. */
  48932. get projectionTextureMatrix(): Matrix;
  48933. protected _projectionTextureLightNear: number;
  48934. /**
  48935. * Gets the near clip of the Spotlight for texture projection.
  48936. */
  48937. get projectionTextureLightNear(): number;
  48938. /**
  48939. * Sets the near clip of the Spotlight for texture projection.
  48940. */
  48941. set projectionTextureLightNear(value: number);
  48942. protected _projectionTextureLightFar: number;
  48943. /**
  48944. * Gets the far clip of the Spotlight for texture projection.
  48945. */
  48946. get projectionTextureLightFar(): number;
  48947. /**
  48948. * Sets the far clip of the Spotlight for texture projection.
  48949. */
  48950. set projectionTextureLightFar(value: number);
  48951. protected _projectionTextureUpDirection: Vector3;
  48952. /**
  48953. * Gets the Up vector of the Spotlight for texture projection.
  48954. */
  48955. get projectionTextureUpDirection(): Vector3;
  48956. /**
  48957. * Sets the Up vector of the Spotlight for texture projection.
  48958. */
  48959. set projectionTextureUpDirection(value: Vector3);
  48960. private _projectionTexture;
  48961. /**
  48962. * Gets the projection texture of the light.
  48963. */
  48964. get projectionTexture(): Nullable<BaseTexture>;
  48965. /**
  48966. * Sets the projection texture of the light.
  48967. */
  48968. set projectionTexture(value: Nullable<BaseTexture>);
  48969. private _projectionTextureViewLightDirty;
  48970. private _projectionTextureProjectionLightDirty;
  48971. private _projectionTextureDirty;
  48972. private _projectionTextureViewTargetVector;
  48973. private _projectionTextureViewLightMatrix;
  48974. private _projectionTextureProjectionLightMatrix;
  48975. private _projectionTextureScalingMatrix;
  48976. /**
  48977. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48978. * It can cast shadows.
  48979. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48980. * @param name The light friendly name
  48981. * @param position The position of the spot light in the scene
  48982. * @param direction The direction of the light in the scene
  48983. * @param angle The cone angle of the light in Radians
  48984. * @param exponent The light decay speed with the distance from the emission spot
  48985. * @param scene The scene the lights belongs to
  48986. */
  48987. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48988. /**
  48989. * Returns the string "SpotLight".
  48990. * @returns the class name
  48991. */
  48992. getClassName(): string;
  48993. /**
  48994. * Returns the integer 2.
  48995. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48996. */
  48997. getTypeID(): number;
  48998. /**
  48999. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49000. */
  49001. protected _setDirection(value: Vector3): void;
  49002. /**
  49003. * Overrides the position setter to recompute the projection texture view light Matrix.
  49004. */
  49005. protected _setPosition(value: Vector3): void;
  49006. /**
  49007. * 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.
  49008. * Returns the SpotLight.
  49009. */
  49010. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49011. protected _computeProjectionTextureViewLightMatrix(): void;
  49012. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49013. /**
  49014. * Main function for light texture projection matrix computing.
  49015. */
  49016. protected _computeProjectionTextureMatrix(): void;
  49017. protected _buildUniformLayout(): void;
  49018. private _computeAngleValues;
  49019. /**
  49020. * Sets the passed Effect "effect" with the Light textures.
  49021. * @param effect The effect to update
  49022. * @param lightIndex The index of the light in the effect to update
  49023. * @returns The light
  49024. */
  49025. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49026. /**
  49027. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49028. * @param effect The effect to update
  49029. * @param lightIndex The index of the light in the effect to update
  49030. * @returns The spot light
  49031. */
  49032. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49033. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49034. /**
  49035. * Disposes the light and the associated resources.
  49036. */
  49037. dispose(): void;
  49038. /**
  49039. * Prepares the list of defines specific to the light type.
  49040. * @param defines the list of defines
  49041. * @param lightIndex defines the index of the light for the effect
  49042. */
  49043. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49044. }
  49045. }
  49046. declare module BABYLON {
  49047. /**
  49048. * Gizmo that enables viewing a light
  49049. */
  49050. export class LightGizmo extends Gizmo {
  49051. private _lightMesh;
  49052. private _material;
  49053. private _cachedPosition;
  49054. private _cachedForward;
  49055. private _attachedMeshParent;
  49056. /**
  49057. * Creates a LightGizmo
  49058. * @param gizmoLayer The utility layer the gizmo will be added to
  49059. */
  49060. constructor(gizmoLayer?: UtilityLayerRenderer);
  49061. private _light;
  49062. /**
  49063. * The light that the gizmo is attached to
  49064. */
  49065. set light(light: Nullable<Light>);
  49066. get light(): Nullable<Light>;
  49067. /**
  49068. * Gets the material used to render the light gizmo
  49069. */
  49070. get material(): StandardMaterial;
  49071. /**
  49072. * @hidden
  49073. * Updates the gizmo to match the attached mesh's position/rotation
  49074. */
  49075. protected _update(): void;
  49076. private static _Scale;
  49077. /**
  49078. * Creates the lines for a light mesh
  49079. */
  49080. private static _CreateLightLines;
  49081. /**
  49082. * Disposes of the light gizmo
  49083. */
  49084. dispose(): void;
  49085. private static _CreateHemisphericLightMesh;
  49086. private static _CreatePointLightMesh;
  49087. private static _CreateSpotLightMesh;
  49088. private static _CreateDirectionalLightMesh;
  49089. }
  49090. }
  49091. declare module BABYLON {
  49092. /** @hidden */
  49093. export var backgroundFragmentDeclaration: {
  49094. name: string;
  49095. shader: string;
  49096. };
  49097. }
  49098. declare module BABYLON {
  49099. /** @hidden */
  49100. export var backgroundUboDeclaration: {
  49101. name: string;
  49102. shader: string;
  49103. };
  49104. }
  49105. declare module BABYLON {
  49106. /** @hidden */
  49107. export var backgroundPixelShader: {
  49108. name: string;
  49109. shader: string;
  49110. };
  49111. }
  49112. declare module BABYLON {
  49113. /** @hidden */
  49114. export var backgroundVertexDeclaration: {
  49115. name: string;
  49116. shader: string;
  49117. };
  49118. }
  49119. declare module BABYLON {
  49120. /** @hidden */
  49121. export var backgroundVertexShader: {
  49122. name: string;
  49123. shader: string;
  49124. };
  49125. }
  49126. declare module BABYLON {
  49127. /**
  49128. * Background material used to create an efficient environement around your scene.
  49129. */
  49130. export class BackgroundMaterial extends PushMaterial {
  49131. /**
  49132. * Standard reflectance value at parallel view angle.
  49133. */
  49134. static StandardReflectance0: number;
  49135. /**
  49136. * Standard reflectance value at grazing angle.
  49137. */
  49138. static StandardReflectance90: number;
  49139. protected _primaryColor: Color3;
  49140. /**
  49141. * Key light Color (multiply against the environement texture)
  49142. */
  49143. primaryColor: Color3;
  49144. protected __perceptualColor: Nullable<Color3>;
  49145. /**
  49146. * Experimental Internal Use Only.
  49147. *
  49148. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49149. * This acts as a helper to set the primary color to a more "human friendly" value.
  49150. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49151. * output color as close as possible from the chosen value.
  49152. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49153. * part of lighting setup.)
  49154. */
  49155. get _perceptualColor(): Nullable<Color3>;
  49156. set _perceptualColor(value: Nullable<Color3>);
  49157. protected _primaryColorShadowLevel: float;
  49158. /**
  49159. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49160. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49161. */
  49162. get primaryColorShadowLevel(): float;
  49163. set primaryColorShadowLevel(value: float);
  49164. protected _primaryColorHighlightLevel: float;
  49165. /**
  49166. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49167. * The primary color is used at the level chosen to define what the white area would look.
  49168. */
  49169. get primaryColorHighlightLevel(): float;
  49170. set primaryColorHighlightLevel(value: float);
  49171. protected _reflectionTexture: Nullable<BaseTexture>;
  49172. /**
  49173. * Reflection Texture used in the material.
  49174. * Should be author in a specific way for the best result (refer to the documentation).
  49175. */
  49176. reflectionTexture: Nullable<BaseTexture>;
  49177. protected _reflectionBlur: float;
  49178. /**
  49179. * Reflection Texture level of blur.
  49180. *
  49181. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49182. * texture twice.
  49183. */
  49184. reflectionBlur: float;
  49185. protected _diffuseTexture: Nullable<BaseTexture>;
  49186. /**
  49187. * Diffuse Texture used in the material.
  49188. * Should be author in a specific way for the best result (refer to the documentation).
  49189. */
  49190. diffuseTexture: Nullable<BaseTexture>;
  49191. protected _shadowLights: Nullable<IShadowLight[]>;
  49192. /**
  49193. * Specify the list of lights casting shadow on the material.
  49194. * All scene shadow lights will be included if null.
  49195. */
  49196. shadowLights: Nullable<IShadowLight[]>;
  49197. protected _shadowLevel: float;
  49198. /**
  49199. * Helps adjusting the shadow to a softer level if required.
  49200. * 0 means black shadows and 1 means no shadows.
  49201. */
  49202. shadowLevel: float;
  49203. protected _sceneCenter: Vector3;
  49204. /**
  49205. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49206. * It is usually zero but might be interesting to modify according to your setup.
  49207. */
  49208. sceneCenter: Vector3;
  49209. protected _opacityFresnel: boolean;
  49210. /**
  49211. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49212. * This helps ensuring a nice transition when the camera goes under the ground.
  49213. */
  49214. opacityFresnel: boolean;
  49215. protected _reflectionFresnel: boolean;
  49216. /**
  49217. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49218. * This helps adding a mirror texture on the ground.
  49219. */
  49220. reflectionFresnel: boolean;
  49221. protected _reflectionFalloffDistance: number;
  49222. /**
  49223. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49224. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49225. */
  49226. reflectionFalloffDistance: number;
  49227. protected _reflectionAmount: number;
  49228. /**
  49229. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49230. */
  49231. reflectionAmount: number;
  49232. protected _reflectionReflectance0: number;
  49233. /**
  49234. * This specifies the weight of the reflection at grazing angle.
  49235. */
  49236. reflectionReflectance0: number;
  49237. protected _reflectionReflectance90: number;
  49238. /**
  49239. * This specifies the weight of the reflection at a perpendicular point of view.
  49240. */
  49241. reflectionReflectance90: number;
  49242. /**
  49243. * Sets the reflection reflectance fresnel values according to the default standard
  49244. * empirically know to work well :-)
  49245. */
  49246. set reflectionStandardFresnelWeight(value: number);
  49247. protected _useRGBColor: boolean;
  49248. /**
  49249. * Helps to directly use the maps channels instead of their level.
  49250. */
  49251. useRGBColor: boolean;
  49252. protected _enableNoise: boolean;
  49253. /**
  49254. * This helps reducing the banding effect that could occur on the background.
  49255. */
  49256. enableNoise: boolean;
  49257. /**
  49258. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49259. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49260. * Recommended to be keep at 1.0 except for special cases.
  49261. */
  49262. get fovMultiplier(): number;
  49263. set fovMultiplier(value: number);
  49264. private _fovMultiplier;
  49265. /**
  49266. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49267. */
  49268. useEquirectangularFOV: boolean;
  49269. private _maxSimultaneousLights;
  49270. /**
  49271. * Number of Simultaneous lights allowed on the material.
  49272. */
  49273. maxSimultaneousLights: int;
  49274. /**
  49275. * Default configuration related to image processing available in the Background Material.
  49276. */
  49277. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49278. /**
  49279. * Keep track of the image processing observer to allow dispose and replace.
  49280. */
  49281. private _imageProcessingObserver;
  49282. /**
  49283. * Attaches a new image processing configuration to the PBR Material.
  49284. * @param configuration (if null the scene configuration will be use)
  49285. */
  49286. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49287. /**
  49288. * Gets the image processing configuration used either in this material.
  49289. */
  49290. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49291. /**
  49292. * Sets the Default image processing configuration used either in the this material.
  49293. *
  49294. * If sets to null, the scene one is in use.
  49295. */
  49296. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49297. /**
  49298. * Gets wether the color curves effect is enabled.
  49299. */
  49300. get cameraColorCurvesEnabled(): boolean;
  49301. /**
  49302. * Sets wether the color curves effect is enabled.
  49303. */
  49304. set cameraColorCurvesEnabled(value: boolean);
  49305. /**
  49306. * Gets wether the color grading effect is enabled.
  49307. */
  49308. get cameraColorGradingEnabled(): boolean;
  49309. /**
  49310. * Gets wether the color grading effect is enabled.
  49311. */
  49312. set cameraColorGradingEnabled(value: boolean);
  49313. /**
  49314. * Gets wether tonemapping is enabled or not.
  49315. */
  49316. get cameraToneMappingEnabled(): boolean;
  49317. /**
  49318. * Sets wether tonemapping is enabled or not
  49319. */
  49320. set cameraToneMappingEnabled(value: boolean);
  49321. /**
  49322. * The camera exposure used on this material.
  49323. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49324. * This corresponds to a photographic exposure.
  49325. */
  49326. get cameraExposure(): float;
  49327. /**
  49328. * The camera exposure used on this material.
  49329. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49330. * This corresponds to a photographic exposure.
  49331. */
  49332. set cameraExposure(value: float);
  49333. /**
  49334. * Gets The camera contrast used on this material.
  49335. */
  49336. get cameraContrast(): float;
  49337. /**
  49338. * Sets The camera contrast used on this material.
  49339. */
  49340. set cameraContrast(value: float);
  49341. /**
  49342. * Gets the Color Grading 2D Lookup Texture.
  49343. */
  49344. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49345. /**
  49346. * Sets the Color Grading 2D Lookup Texture.
  49347. */
  49348. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49349. /**
  49350. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49351. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49352. * 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;
  49353. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49354. */
  49355. get cameraColorCurves(): Nullable<ColorCurves>;
  49356. /**
  49357. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49358. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49359. * 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;
  49360. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49361. */
  49362. set cameraColorCurves(value: Nullable<ColorCurves>);
  49363. /**
  49364. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49365. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49366. */
  49367. switchToBGR: boolean;
  49368. private _renderTargets;
  49369. private _reflectionControls;
  49370. private _white;
  49371. private _primaryShadowColor;
  49372. private _primaryHighlightColor;
  49373. /**
  49374. * Instantiates a Background Material in the given scene
  49375. * @param name The friendly name of the material
  49376. * @param scene The scene to add the material to
  49377. */
  49378. constructor(name: string, scene: Scene);
  49379. /**
  49380. * Gets a boolean indicating that current material needs to register RTT
  49381. */
  49382. get hasRenderTargetTextures(): boolean;
  49383. /**
  49384. * The entire material has been created in order to prevent overdraw.
  49385. * @returns false
  49386. */
  49387. needAlphaTesting(): boolean;
  49388. /**
  49389. * The entire material has been created in order to prevent overdraw.
  49390. * @returns true if blending is enable
  49391. */
  49392. needAlphaBlending(): boolean;
  49393. /**
  49394. * Checks wether the material is ready to be rendered for a given mesh.
  49395. * @param mesh The mesh to render
  49396. * @param subMesh The submesh to check against
  49397. * @param useInstances Specify wether or not the material is used with instances
  49398. * @returns true if all the dependencies are ready (Textures, Effects...)
  49399. */
  49400. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49401. /**
  49402. * Compute the primary color according to the chosen perceptual color.
  49403. */
  49404. private _computePrimaryColorFromPerceptualColor;
  49405. /**
  49406. * Compute the highlights and shadow colors according to their chosen levels.
  49407. */
  49408. private _computePrimaryColors;
  49409. /**
  49410. * Build the uniform buffer used in the material.
  49411. */
  49412. buildUniformLayout(): void;
  49413. /**
  49414. * Unbind the material.
  49415. */
  49416. unbind(): void;
  49417. /**
  49418. * Bind only the world matrix to the material.
  49419. * @param world The world matrix to bind.
  49420. */
  49421. bindOnlyWorldMatrix(world: Matrix): void;
  49422. /**
  49423. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49424. * @param world The world matrix to bind.
  49425. * @param subMesh The submesh to bind for.
  49426. */
  49427. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49428. /**
  49429. * Checks to see if a texture is used in the material.
  49430. * @param texture - Base texture to use.
  49431. * @returns - Boolean specifying if a texture is used in the material.
  49432. */
  49433. hasTexture(texture: BaseTexture): boolean;
  49434. /**
  49435. * Dispose the material.
  49436. * @param forceDisposeEffect Force disposal of the associated effect.
  49437. * @param forceDisposeTextures Force disposal of the associated textures.
  49438. */
  49439. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49440. /**
  49441. * Clones the material.
  49442. * @param name The cloned name.
  49443. * @returns The cloned material.
  49444. */
  49445. clone(name: string): BackgroundMaterial;
  49446. /**
  49447. * Serializes the current material to its JSON representation.
  49448. * @returns The JSON representation.
  49449. */
  49450. serialize(): any;
  49451. /**
  49452. * Gets the class name of the material
  49453. * @returns "BackgroundMaterial"
  49454. */
  49455. getClassName(): string;
  49456. /**
  49457. * Parse a JSON input to create back a background material.
  49458. * @param source The JSON data to parse
  49459. * @param scene The scene to create the parsed material in
  49460. * @param rootUrl The root url of the assets the material depends upon
  49461. * @returns the instantiated BackgroundMaterial.
  49462. */
  49463. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49464. }
  49465. }
  49466. declare module BABYLON {
  49467. /**
  49468. * Represents the different options available during the creation of
  49469. * a Environment helper.
  49470. *
  49471. * This can control the default ground, skybox and image processing setup of your scene.
  49472. */
  49473. export interface IEnvironmentHelperOptions {
  49474. /**
  49475. * Specifies whether or not to create a ground.
  49476. * True by default.
  49477. */
  49478. createGround: boolean;
  49479. /**
  49480. * Specifies the ground size.
  49481. * 15 by default.
  49482. */
  49483. groundSize: number;
  49484. /**
  49485. * The texture used on the ground for the main color.
  49486. * Comes from the BabylonJS CDN by default.
  49487. *
  49488. * Remarks: Can be either a texture or a url.
  49489. */
  49490. groundTexture: string | BaseTexture;
  49491. /**
  49492. * The color mixed in the ground texture by default.
  49493. * BabylonJS clearColor by default.
  49494. */
  49495. groundColor: Color3;
  49496. /**
  49497. * Specifies the ground opacity.
  49498. * 1 by default.
  49499. */
  49500. groundOpacity: number;
  49501. /**
  49502. * Enables the ground to receive shadows.
  49503. * True by default.
  49504. */
  49505. enableGroundShadow: boolean;
  49506. /**
  49507. * Helps preventing the shadow to be fully black on the ground.
  49508. * 0.5 by default.
  49509. */
  49510. groundShadowLevel: number;
  49511. /**
  49512. * Creates a mirror texture attach to the ground.
  49513. * false by default.
  49514. */
  49515. enableGroundMirror: boolean;
  49516. /**
  49517. * Specifies the ground mirror size ratio.
  49518. * 0.3 by default as the default kernel is 64.
  49519. */
  49520. groundMirrorSizeRatio: number;
  49521. /**
  49522. * Specifies the ground mirror blur kernel size.
  49523. * 64 by default.
  49524. */
  49525. groundMirrorBlurKernel: number;
  49526. /**
  49527. * Specifies the ground mirror visibility amount.
  49528. * 1 by default
  49529. */
  49530. groundMirrorAmount: number;
  49531. /**
  49532. * Specifies the ground mirror reflectance weight.
  49533. * This uses the standard weight of the background material to setup the fresnel effect
  49534. * of the mirror.
  49535. * 1 by default.
  49536. */
  49537. groundMirrorFresnelWeight: number;
  49538. /**
  49539. * Specifies the ground mirror Falloff distance.
  49540. * This can helps reducing the size of the reflection.
  49541. * 0 by Default.
  49542. */
  49543. groundMirrorFallOffDistance: number;
  49544. /**
  49545. * Specifies the ground mirror texture type.
  49546. * Unsigned Int by Default.
  49547. */
  49548. groundMirrorTextureType: number;
  49549. /**
  49550. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49551. * the shown objects.
  49552. */
  49553. groundYBias: number;
  49554. /**
  49555. * Specifies whether or not to create a skybox.
  49556. * True by default.
  49557. */
  49558. createSkybox: boolean;
  49559. /**
  49560. * Specifies the skybox size.
  49561. * 20 by default.
  49562. */
  49563. skyboxSize: number;
  49564. /**
  49565. * The texture used on the skybox for the main color.
  49566. * Comes from the BabylonJS CDN by default.
  49567. *
  49568. * Remarks: Can be either a texture or a url.
  49569. */
  49570. skyboxTexture: string | BaseTexture;
  49571. /**
  49572. * The color mixed in the skybox texture by default.
  49573. * BabylonJS clearColor by default.
  49574. */
  49575. skyboxColor: Color3;
  49576. /**
  49577. * The background rotation around the Y axis of the scene.
  49578. * This helps aligning the key lights of your scene with the background.
  49579. * 0 by default.
  49580. */
  49581. backgroundYRotation: number;
  49582. /**
  49583. * Compute automatically the size of the elements to best fit with the scene.
  49584. */
  49585. sizeAuto: boolean;
  49586. /**
  49587. * Default position of the rootMesh if autoSize is not true.
  49588. */
  49589. rootPosition: Vector3;
  49590. /**
  49591. * Sets up the image processing in the scene.
  49592. * true by default.
  49593. */
  49594. setupImageProcessing: boolean;
  49595. /**
  49596. * The texture used as your environment texture in the scene.
  49597. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49598. *
  49599. * Remarks: Can be either a texture or a url.
  49600. */
  49601. environmentTexture: string | BaseTexture;
  49602. /**
  49603. * The value of the exposure to apply to the scene.
  49604. * 0.6 by default if setupImageProcessing is true.
  49605. */
  49606. cameraExposure: number;
  49607. /**
  49608. * The value of the contrast to apply to the scene.
  49609. * 1.6 by default if setupImageProcessing is true.
  49610. */
  49611. cameraContrast: number;
  49612. /**
  49613. * Specifies whether or not tonemapping should be enabled in the scene.
  49614. * true by default if setupImageProcessing is true.
  49615. */
  49616. toneMappingEnabled: boolean;
  49617. }
  49618. /**
  49619. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49620. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49621. * It also helps with the default setup of your imageProcessing configuration.
  49622. */
  49623. export class EnvironmentHelper {
  49624. /**
  49625. * Default ground texture URL.
  49626. */
  49627. private static _groundTextureCDNUrl;
  49628. /**
  49629. * Default skybox texture URL.
  49630. */
  49631. private static _skyboxTextureCDNUrl;
  49632. /**
  49633. * Default environment texture URL.
  49634. */
  49635. private static _environmentTextureCDNUrl;
  49636. /**
  49637. * Creates the default options for the helper.
  49638. */
  49639. private static _getDefaultOptions;
  49640. private _rootMesh;
  49641. /**
  49642. * Gets the root mesh created by the helper.
  49643. */
  49644. get rootMesh(): Mesh;
  49645. private _skybox;
  49646. /**
  49647. * Gets the skybox created by the helper.
  49648. */
  49649. get skybox(): Nullable<Mesh>;
  49650. private _skyboxTexture;
  49651. /**
  49652. * Gets the skybox texture created by the helper.
  49653. */
  49654. get skyboxTexture(): Nullable<BaseTexture>;
  49655. private _skyboxMaterial;
  49656. /**
  49657. * Gets the skybox material created by the helper.
  49658. */
  49659. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49660. private _ground;
  49661. /**
  49662. * Gets the ground mesh created by the helper.
  49663. */
  49664. get ground(): Nullable<Mesh>;
  49665. private _groundTexture;
  49666. /**
  49667. * Gets the ground texture created by the helper.
  49668. */
  49669. get groundTexture(): Nullable<BaseTexture>;
  49670. private _groundMirror;
  49671. /**
  49672. * Gets the ground mirror created by the helper.
  49673. */
  49674. get groundMirror(): Nullable<MirrorTexture>;
  49675. /**
  49676. * Gets the ground mirror render list to helps pushing the meshes
  49677. * you wish in the ground reflection.
  49678. */
  49679. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49680. private _groundMaterial;
  49681. /**
  49682. * Gets the ground material created by the helper.
  49683. */
  49684. get groundMaterial(): Nullable<BackgroundMaterial>;
  49685. /**
  49686. * Stores the creation options.
  49687. */
  49688. private readonly _scene;
  49689. private _options;
  49690. /**
  49691. * This observable will be notified with any error during the creation of the environment,
  49692. * mainly texture creation errors.
  49693. */
  49694. onErrorObservable: Observable<{
  49695. message?: string;
  49696. exception?: any;
  49697. }>;
  49698. /**
  49699. * constructor
  49700. * @param options Defines the options we want to customize the helper
  49701. * @param scene The scene to add the material to
  49702. */
  49703. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49704. /**
  49705. * Updates the background according to the new options
  49706. * @param options
  49707. */
  49708. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49709. /**
  49710. * Sets the primary color of all the available elements.
  49711. * @param color the main color to affect to the ground and the background
  49712. */
  49713. setMainColor(color: Color3): void;
  49714. /**
  49715. * Setup the image processing according to the specified options.
  49716. */
  49717. private _setupImageProcessing;
  49718. /**
  49719. * Setup the environment texture according to the specified options.
  49720. */
  49721. private _setupEnvironmentTexture;
  49722. /**
  49723. * Setup the background according to the specified options.
  49724. */
  49725. private _setupBackground;
  49726. /**
  49727. * Get the scene sizes according to the setup.
  49728. */
  49729. private _getSceneSize;
  49730. /**
  49731. * Setup the ground according to the specified options.
  49732. */
  49733. private _setupGround;
  49734. /**
  49735. * Setup the ground material according to the specified options.
  49736. */
  49737. private _setupGroundMaterial;
  49738. /**
  49739. * Setup the ground diffuse texture according to the specified options.
  49740. */
  49741. private _setupGroundDiffuseTexture;
  49742. /**
  49743. * Setup the ground mirror texture according to the specified options.
  49744. */
  49745. private _setupGroundMirrorTexture;
  49746. /**
  49747. * Setup the ground to receive the mirror texture.
  49748. */
  49749. private _setupMirrorInGroundMaterial;
  49750. /**
  49751. * Setup the skybox according to the specified options.
  49752. */
  49753. private _setupSkybox;
  49754. /**
  49755. * Setup the skybox material according to the specified options.
  49756. */
  49757. private _setupSkyboxMaterial;
  49758. /**
  49759. * Setup the skybox reflection texture according to the specified options.
  49760. */
  49761. private _setupSkyboxReflectionTexture;
  49762. private _errorHandler;
  49763. /**
  49764. * Dispose all the elements created by the Helper.
  49765. */
  49766. dispose(): void;
  49767. }
  49768. }
  49769. declare module BABYLON {
  49770. /**
  49771. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49772. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49773. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49774. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49775. */
  49776. export class PhotoDome extends TransformNode {
  49777. /**
  49778. * Define the image as a Monoscopic panoramic 360 image.
  49779. */
  49780. static readonly MODE_MONOSCOPIC: number;
  49781. /**
  49782. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49783. */
  49784. static readonly MODE_TOPBOTTOM: number;
  49785. /**
  49786. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49787. */
  49788. static readonly MODE_SIDEBYSIDE: number;
  49789. private _useDirectMapping;
  49790. /**
  49791. * The texture being displayed on the sphere
  49792. */
  49793. protected _photoTexture: Texture;
  49794. /**
  49795. * Gets or sets the texture being displayed on the sphere
  49796. */
  49797. get photoTexture(): Texture;
  49798. set photoTexture(value: Texture);
  49799. /**
  49800. * Observable raised when an error occured while loading the 360 image
  49801. */
  49802. onLoadErrorObservable: Observable<string>;
  49803. /**
  49804. * The skybox material
  49805. */
  49806. protected _material: BackgroundMaterial;
  49807. /**
  49808. * The surface used for the skybox
  49809. */
  49810. protected _mesh: Mesh;
  49811. /**
  49812. * Gets the mesh used for the skybox.
  49813. */
  49814. get mesh(): Mesh;
  49815. /**
  49816. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49817. * Also see the options.resolution property.
  49818. */
  49819. get fovMultiplier(): number;
  49820. set fovMultiplier(value: number);
  49821. private _imageMode;
  49822. /**
  49823. * Gets or set the current video mode for the video. It can be:
  49824. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49825. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49826. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49827. */
  49828. get imageMode(): number;
  49829. set imageMode(value: number);
  49830. /**
  49831. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49832. * @param name Element's name, child elements will append suffixes for their own names.
  49833. * @param urlsOfPhoto defines the url of the photo to display
  49834. * @param options defines an object containing optional or exposed sub element properties
  49835. * @param onError defines a callback called when an error occured while loading the texture
  49836. */
  49837. constructor(name: string, urlOfPhoto: string, options: {
  49838. resolution?: number;
  49839. size?: number;
  49840. useDirectMapping?: boolean;
  49841. faceForward?: boolean;
  49842. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49843. private _onBeforeCameraRenderObserver;
  49844. private _changeImageMode;
  49845. /**
  49846. * Releases resources associated with this node.
  49847. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49848. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49849. */
  49850. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49851. }
  49852. }
  49853. declare module BABYLON {
  49854. /**
  49855. * Class used to host RGBD texture specific utilities
  49856. */
  49857. export class RGBDTextureTools {
  49858. /**
  49859. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49860. * @param texture the texture to expand.
  49861. */
  49862. static ExpandRGBDTexture(texture: Texture): void;
  49863. }
  49864. }
  49865. declare module BABYLON {
  49866. /**
  49867. * Class used to host texture specific utilities
  49868. */
  49869. export class BRDFTextureTools {
  49870. /**
  49871. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49872. * @param scene defines the hosting scene
  49873. * @returns the environment BRDF texture
  49874. */
  49875. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49876. private static _environmentBRDFBase64Texture;
  49877. }
  49878. }
  49879. declare module BABYLON {
  49880. /**
  49881. * @hidden
  49882. */
  49883. export interface IMaterialClearCoatDefines {
  49884. CLEARCOAT: boolean;
  49885. CLEARCOAT_DEFAULTIOR: boolean;
  49886. CLEARCOAT_TEXTURE: boolean;
  49887. CLEARCOAT_TEXTUREDIRECTUV: number;
  49888. CLEARCOAT_BUMP: boolean;
  49889. CLEARCOAT_BUMPDIRECTUV: number;
  49890. CLEARCOAT_TINT: boolean;
  49891. CLEARCOAT_TINT_TEXTURE: boolean;
  49892. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49893. /** @hidden */
  49894. _areTexturesDirty: boolean;
  49895. }
  49896. /**
  49897. * Define the code related to the clear coat parameters of the pbr material.
  49898. */
  49899. export class PBRClearCoatConfiguration {
  49900. /**
  49901. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49902. * The default fits with a polyurethane material.
  49903. */
  49904. private static readonly _DefaultIndexOfRefraction;
  49905. private _isEnabled;
  49906. /**
  49907. * Defines if the clear coat is enabled in the material.
  49908. */
  49909. isEnabled: boolean;
  49910. /**
  49911. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49912. */
  49913. intensity: number;
  49914. /**
  49915. * Defines the clear coat layer roughness.
  49916. */
  49917. roughness: number;
  49918. private _indexOfRefraction;
  49919. /**
  49920. * Defines the index of refraction of the clear coat.
  49921. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49922. * The default fits with a polyurethane material.
  49923. * Changing the default value is more performance intensive.
  49924. */
  49925. indexOfRefraction: number;
  49926. private _texture;
  49927. /**
  49928. * Stores the clear coat values in a texture.
  49929. */
  49930. texture: Nullable<BaseTexture>;
  49931. private _bumpTexture;
  49932. /**
  49933. * Define the clear coat specific bump texture.
  49934. */
  49935. bumpTexture: Nullable<BaseTexture>;
  49936. private _isTintEnabled;
  49937. /**
  49938. * Defines if the clear coat tint is enabled in the material.
  49939. */
  49940. isTintEnabled: boolean;
  49941. /**
  49942. * Defines the clear coat tint of the material.
  49943. * This is only use if tint is enabled
  49944. */
  49945. tintColor: Color3;
  49946. /**
  49947. * Defines the distance at which the tint color should be found in the
  49948. * clear coat media.
  49949. * This is only use if tint is enabled
  49950. */
  49951. tintColorAtDistance: number;
  49952. /**
  49953. * Defines the clear coat layer thickness.
  49954. * This is only use if tint is enabled
  49955. */
  49956. tintThickness: number;
  49957. private _tintTexture;
  49958. /**
  49959. * Stores the clear tint values in a texture.
  49960. * rgb is tint
  49961. * a is a thickness factor
  49962. */
  49963. tintTexture: Nullable<BaseTexture>;
  49964. /** @hidden */
  49965. private _internalMarkAllSubMeshesAsTexturesDirty;
  49966. /** @hidden */
  49967. _markAllSubMeshesAsTexturesDirty(): void;
  49968. /**
  49969. * Instantiate a new istance of clear coat configuration.
  49970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49971. */
  49972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49973. /**
  49974. * Gets wehter the submesh is ready to be used or not.
  49975. * @param defines the list of "defines" to update.
  49976. * @param scene defines the scene the material belongs to.
  49977. * @param engine defines the engine the material belongs to.
  49978. * @param disableBumpMap defines wether the material disables bump or not.
  49979. * @returns - boolean indicating that the submesh is ready or not.
  49980. */
  49981. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49982. /**
  49983. * Checks to see if a texture is used in the material.
  49984. * @param defines the list of "defines" to update.
  49985. * @param scene defines the scene to the material belongs to.
  49986. */
  49987. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49988. /**
  49989. * Binds the material data.
  49990. * @param uniformBuffer defines the Uniform buffer to fill in.
  49991. * @param scene defines the scene the material belongs to.
  49992. * @param engine defines the engine the material belongs to.
  49993. * @param disableBumpMap defines wether the material disables bump or not.
  49994. * @param isFrozen defines wether the material is frozen or not.
  49995. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49996. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49997. */
  49998. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49999. /**
  50000. * Checks to see if a texture is used in the material.
  50001. * @param texture - Base texture to use.
  50002. * @returns - Boolean specifying if a texture is used in the material.
  50003. */
  50004. hasTexture(texture: BaseTexture): boolean;
  50005. /**
  50006. * Returns an array of the actively used textures.
  50007. * @param activeTextures Array of BaseTextures
  50008. */
  50009. getActiveTextures(activeTextures: BaseTexture[]): void;
  50010. /**
  50011. * Returns the animatable textures.
  50012. * @param animatables Array of animatable textures.
  50013. */
  50014. getAnimatables(animatables: IAnimatable[]): void;
  50015. /**
  50016. * Disposes the resources of the material.
  50017. * @param forceDisposeTextures - Forces the disposal of all textures.
  50018. */
  50019. dispose(forceDisposeTextures?: boolean): void;
  50020. /**
  50021. * Get the current class name of the texture useful for serialization or dynamic coding.
  50022. * @returns "PBRClearCoatConfiguration"
  50023. */
  50024. getClassName(): string;
  50025. /**
  50026. * Add fallbacks to the effect fallbacks list.
  50027. * @param defines defines the Base texture to use.
  50028. * @param fallbacks defines the current fallback list.
  50029. * @param currentRank defines the current fallback rank.
  50030. * @returns the new fallback rank.
  50031. */
  50032. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50033. /**
  50034. * Add the required uniforms to the current list.
  50035. * @param uniforms defines the current uniform list.
  50036. */
  50037. static AddUniforms(uniforms: string[]): void;
  50038. /**
  50039. * Add the required samplers to the current list.
  50040. * @param samplers defines the current sampler list.
  50041. */
  50042. static AddSamplers(samplers: string[]): void;
  50043. /**
  50044. * Add the required uniforms to the current buffer.
  50045. * @param uniformBuffer defines the current uniform buffer.
  50046. */
  50047. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50048. /**
  50049. * Makes a duplicate of the current configuration into another one.
  50050. * @param clearCoatConfiguration define the config where to copy the info
  50051. */
  50052. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50053. /**
  50054. * Serializes this clear coat configuration.
  50055. * @returns - An object with the serialized config.
  50056. */
  50057. serialize(): any;
  50058. /**
  50059. * Parses a anisotropy Configuration from a serialized object.
  50060. * @param source - Serialized object.
  50061. * @param scene Defines the scene we are parsing for
  50062. * @param rootUrl Defines the rootUrl to load from
  50063. */
  50064. parse(source: any, scene: Scene, rootUrl: string): void;
  50065. }
  50066. }
  50067. declare module BABYLON {
  50068. /**
  50069. * @hidden
  50070. */
  50071. export interface IMaterialAnisotropicDefines {
  50072. ANISOTROPIC: boolean;
  50073. ANISOTROPIC_TEXTURE: boolean;
  50074. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50075. MAINUV1: boolean;
  50076. _areTexturesDirty: boolean;
  50077. _needUVs: boolean;
  50078. }
  50079. /**
  50080. * Define the code related to the anisotropic parameters of the pbr material.
  50081. */
  50082. export class PBRAnisotropicConfiguration {
  50083. private _isEnabled;
  50084. /**
  50085. * Defines if the anisotropy is enabled in the material.
  50086. */
  50087. isEnabled: boolean;
  50088. /**
  50089. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50090. */
  50091. intensity: number;
  50092. /**
  50093. * Defines if the effect is along the tangents, bitangents or in between.
  50094. * By default, the effect is "strectching" the highlights along the tangents.
  50095. */
  50096. direction: Vector2;
  50097. private _texture;
  50098. /**
  50099. * Stores the anisotropy values in a texture.
  50100. * rg is direction (like normal from -1 to 1)
  50101. * b is a intensity
  50102. */
  50103. texture: Nullable<BaseTexture>;
  50104. /** @hidden */
  50105. private _internalMarkAllSubMeshesAsTexturesDirty;
  50106. /** @hidden */
  50107. _markAllSubMeshesAsTexturesDirty(): void;
  50108. /**
  50109. * Instantiate a new istance of anisotropy configuration.
  50110. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50111. */
  50112. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50113. /**
  50114. * Specifies that the submesh is ready to be used.
  50115. * @param defines the list of "defines" to update.
  50116. * @param scene defines the scene the material belongs to.
  50117. * @returns - boolean indicating that the submesh is ready or not.
  50118. */
  50119. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50120. /**
  50121. * Checks to see if a texture is used in the material.
  50122. * @param defines the list of "defines" to update.
  50123. * @param mesh the mesh we are preparing the defines for.
  50124. * @param scene defines the scene the material belongs to.
  50125. */
  50126. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50127. /**
  50128. * Binds the material data.
  50129. * @param uniformBuffer defines the Uniform buffer to fill in.
  50130. * @param scene defines the scene the material belongs to.
  50131. * @param isFrozen defines wether the material is frozen or not.
  50132. */
  50133. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50134. /**
  50135. * Checks to see if a texture is used in the material.
  50136. * @param texture - Base texture to use.
  50137. * @returns - Boolean specifying if a texture is used in the material.
  50138. */
  50139. hasTexture(texture: BaseTexture): boolean;
  50140. /**
  50141. * Returns an array of the actively used textures.
  50142. * @param activeTextures Array of BaseTextures
  50143. */
  50144. getActiveTextures(activeTextures: BaseTexture[]): void;
  50145. /**
  50146. * Returns the animatable textures.
  50147. * @param animatables Array of animatable textures.
  50148. */
  50149. getAnimatables(animatables: IAnimatable[]): void;
  50150. /**
  50151. * Disposes the resources of the material.
  50152. * @param forceDisposeTextures - Forces the disposal of all textures.
  50153. */
  50154. dispose(forceDisposeTextures?: boolean): void;
  50155. /**
  50156. * Get the current class name of the texture useful for serialization or dynamic coding.
  50157. * @returns "PBRAnisotropicConfiguration"
  50158. */
  50159. getClassName(): string;
  50160. /**
  50161. * Add fallbacks to the effect fallbacks list.
  50162. * @param defines defines the Base texture to use.
  50163. * @param fallbacks defines the current fallback list.
  50164. * @param currentRank defines the current fallback rank.
  50165. * @returns the new fallback rank.
  50166. */
  50167. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50168. /**
  50169. * Add the required uniforms to the current list.
  50170. * @param uniforms defines the current uniform list.
  50171. */
  50172. static AddUniforms(uniforms: string[]): void;
  50173. /**
  50174. * Add the required uniforms to the current buffer.
  50175. * @param uniformBuffer defines the current uniform buffer.
  50176. */
  50177. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50178. /**
  50179. * Add the required samplers to the current list.
  50180. * @param samplers defines the current sampler list.
  50181. */
  50182. static AddSamplers(samplers: string[]): void;
  50183. /**
  50184. * Makes a duplicate of the current configuration into another one.
  50185. * @param anisotropicConfiguration define the config where to copy the info
  50186. */
  50187. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50188. /**
  50189. * Serializes this anisotropy configuration.
  50190. * @returns - An object with the serialized config.
  50191. */
  50192. serialize(): any;
  50193. /**
  50194. * Parses a anisotropy Configuration from a serialized object.
  50195. * @param source - Serialized object.
  50196. * @param scene Defines the scene we are parsing for
  50197. * @param rootUrl Defines the rootUrl to load from
  50198. */
  50199. parse(source: any, scene: Scene, rootUrl: string): void;
  50200. }
  50201. }
  50202. declare module BABYLON {
  50203. /**
  50204. * @hidden
  50205. */
  50206. export interface IMaterialBRDFDefines {
  50207. BRDF_V_HEIGHT_CORRELATED: boolean;
  50208. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50209. SPHERICAL_HARMONICS: boolean;
  50210. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50211. /** @hidden */
  50212. _areMiscDirty: boolean;
  50213. }
  50214. /**
  50215. * Define the code related to the BRDF parameters of the pbr material.
  50216. */
  50217. export class PBRBRDFConfiguration {
  50218. /**
  50219. * Default value used for the energy conservation.
  50220. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50221. */
  50222. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50223. /**
  50224. * Default value used for the Smith Visibility Height Correlated mode.
  50225. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50226. */
  50227. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50228. /**
  50229. * Default value used for the IBL diffuse part.
  50230. * This can help switching back to the polynomials mode globally which is a tiny bit
  50231. * less GPU intensive at the drawback of a lower quality.
  50232. */
  50233. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50234. /**
  50235. * Default value used for activating energy conservation for the specular workflow.
  50236. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50237. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50238. */
  50239. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50240. private _useEnergyConservation;
  50241. /**
  50242. * Defines if the material uses energy conservation.
  50243. */
  50244. useEnergyConservation: boolean;
  50245. private _useSmithVisibilityHeightCorrelated;
  50246. /**
  50247. * LEGACY Mode set to false
  50248. * Defines if the material uses height smith correlated visibility term.
  50249. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50250. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50251. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50252. * Not relying on height correlated will also disable energy conservation.
  50253. */
  50254. useSmithVisibilityHeightCorrelated: boolean;
  50255. private _useSphericalHarmonics;
  50256. /**
  50257. * LEGACY Mode set to false
  50258. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50259. * diffuse part of the IBL.
  50260. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50261. * to the ground truth.
  50262. */
  50263. useSphericalHarmonics: boolean;
  50264. private _useSpecularGlossinessInputEnergyConservation;
  50265. /**
  50266. * Defines if the material uses energy conservation, when the specular workflow is active.
  50267. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50268. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50269. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50270. */
  50271. useSpecularGlossinessInputEnergyConservation: boolean;
  50272. /** @hidden */
  50273. private _internalMarkAllSubMeshesAsMiscDirty;
  50274. /** @hidden */
  50275. _markAllSubMeshesAsMiscDirty(): void;
  50276. /**
  50277. * Instantiate a new istance of clear coat configuration.
  50278. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50279. */
  50280. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50281. /**
  50282. * Checks to see if a texture is used in the material.
  50283. * @param defines the list of "defines" to update.
  50284. */
  50285. prepareDefines(defines: IMaterialBRDFDefines): void;
  50286. /**
  50287. * Get the current class name of the texture useful for serialization or dynamic coding.
  50288. * @returns "PBRClearCoatConfiguration"
  50289. */
  50290. getClassName(): string;
  50291. /**
  50292. * Makes a duplicate of the current configuration into another one.
  50293. * @param brdfConfiguration define the config where to copy the info
  50294. */
  50295. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50296. /**
  50297. * Serializes this BRDF configuration.
  50298. * @returns - An object with the serialized config.
  50299. */
  50300. serialize(): any;
  50301. /**
  50302. * Parses a anisotropy Configuration from a serialized object.
  50303. * @param source - Serialized object.
  50304. * @param scene Defines the scene we are parsing for
  50305. * @param rootUrl Defines the rootUrl to load from
  50306. */
  50307. parse(source: any, scene: Scene, rootUrl: string): void;
  50308. }
  50309. }
  50310. declare module BABYLON {
  50311. /**
  50312. * @hidden
  50313. */
  50314. export interface IMaterialSheenDefines {
  50315. SHEEN: boolean;
  50316. SHEEN_TEXTURE: boolean;
  50317. SHEEN_TEXTUREDIRECTUV: number;
  50318. SHEEN_LINKWITHALBEDO: boolean;
  50319. /** @hidden */
  50320. _areTexturesDirty: boolean;
  50321. }
  50322. /**
  50323. * Define the code related to the Sheen parameters of the pbr material.
  50324. */
  50325. export class PBRSheenConfiguration {
  50326. private _isEnabled;
  50327. /**
  50328. * Defines if the material uses sheen.
  50329. */
  50330. isEnabled: boolean;
  50331. private _linkSheenWithAlbedo;
  50332. /**
  50333. * Defines if the sheen is linked to the sheen color.
  50334. */
  50335. linkSheenWithAlbedo: boolean;
  50336. /**
  50337. * Defines the sheen intensity.
  50338. */
  50339. intensity: number;
  50340. /**
  50341. * Defines the sheen color.
  50342. */
  50343. color: Color3;
  50344. private _texture;
  50345. /**
  50346. * Stores the sheen tint values in a texture.
  50347. * rgb is tint
  50348. * a is a intensity
  50349. */
  50350. texture: Nullable<BaseTexture>;
  50351. /** @hidden */
  50352. private _internalMarkAllSubMeshesAsTexturesDirty;
  50353. /** @hidden */
  50354. _markAllSubMeshesAsTexturesDirty(): void;
  50355. /**
  50356. * Instantiate a new istance of clear coat configuration.
  50357. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50358. */
  50359. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50360. /**
  50361. * Specifies that the submesh is ready to be used.
  50362. * @param defines the list of "defines" to update.
  50363. * @param scene defines the scene the material belongs to.
  50364. * @returns - boolean indicating that the submesh is ready or not.
  50365. */
  50366. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50367. /**
  50368. * Checks to see if a texture is used in the material.
  50369. * @param defines the list of "defines" to update.
  50370. * @param scene defines the scene the material belongs to.
  50371. */
  50372. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50373. /**
  50374. * Binds the material data.
  50375. * @param uniformBuffer defines the Uniform buffer to fill in.
  50376. * @param scene defines the scene the material belongs to.
  50377. * @param isFrozen defines wether the material is frozen or not.
  50378. */
  50379. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50380. /**
  50381. * Checks to see if a texture is used in the material.
  50382. * @param texture - Base texture to use.
  50383. * @returns - Boolean specifying if a texture is used in the material.
  50384. */
  50385. hasTexture(texture: BaseTexture): boolean;
  50386. /**
  50387. * Returns an array of the actively used textures.
  50388. * @param activeTextures Array of BaseTextures
  50389. */
  50390. getActiveTextures(activeTextures: BaseTexture[]): void;
  50391. /**
  50392. * Returns the animatable textures.
  50393. * @param animatables Array of animatable textures.
  50394. */
  50395. getAnimatables(animatables: IAnimatable[]): void;
  50396. /**
  50397. * Disposes the resources of the material.
  50398. * @param forceDisposeTextures - Forces the disposal of all textures.
  50399. */
  50400. dispose(forceDisposeTextures?: boolean): void;
  50401. /**
  50402. * Get the current class name of the texture useful for serialization or dynamic coding.
  50403. * @returns "PBRSheenConfiguration"
  50404. */
  50405. getClassName(): string;
  50406. /**
  50407. * Add fallbacks to the effect fallbacks list.
  50408. * @param defines defines the Base texture to use.
  50409. * @param fallbacks defines the current fallback list.
  50410. * @param currentRank defines the current fallback rank.
  50411. * @returns the new fallback rank.
  50412. */
  50413. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50414. /**
  50415. * Add the required uniforms to the current list.
  50416. * @param uniforms defines the current uniform list.
  50417. */
  50418. static AddUniforms(uniforms: string[]): void;
  50419. /**
  50420. * Add the required uniforms to the current buffer.
  50421. * @param uniformBuffer defines the current uniform buffer.
  50422. */
  50423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50424. /**
  50425. * Add the required samplers to the current list.
  50426. * @param samplers defines the current sampler list.
  50427. */
  50428. static AddSamplers(samplers: string[]): void;
  50429. /**
  50430. * Makes a duplicate of the current configuration into another one.
  50431. * @param sheenConfiguration define the config where to copy the info
  50432. */
  50433. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50434. /**
  50435. * Serializes this BRDF configuration.
  50436. * @returns - An object with the serialized config.
  50437. */
  50438. serialize(): any;
  50439. /**
  50440. * Parses a anisotropy Configuration from a serialized object.
  50441. * @param source - Serialized object.
  50442. * @param scene Defines the scene we are parsing for
  50443. * @param rootUrl Defines the rootUrl to load from
  50444. */
  50445. parse(source: any, scene: Scene, rootUrl: string): void;
  50446. }
  50447. }
  50448. declare module BABYLON {
  50449. /**
  50450. * @hidden
  50451. */
  50452. export interface IMaterialSubSurfaceDefines {
  50453. SUBSURFACE: boolean;
  50454. SS_REFRACTION: boolean;
  50455. SS_TRANSLUCENCY: boolean;
  50456. SS_SCATERRING: boolean;
  50457. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50458. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50459. SS_REFRACTIONMAP_3D: boolean;
  50460. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50461. SS_LODINREFRACTIONALPHA: boolean;
  50462. SS_GAMMAREFRACTION: boolean;
  50463. SS_RGBDREFRACTION: boolean;
  50464. SS_LINEARSPECULARREFRACTION: boolean;
  50465. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50466. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50467. /** @hidden */
  50468. _areTexturesDirty: boolean;
  50469. }
  50470. /**
  50471. * Define the code related to the sub surface parameters of the pbr material.
  50472. */
  50473. export class PBRSubSurfaceConfiguration {
  50474. private _isRefractionEnabled;
  50475. /**
  50476. * Defines if the refraction is enabled in the material.
  50477. */
  50478. isRefractionEnabled: boolean;
  50479. private _isTranslucencyEnabled;
  50480. /**
  50481. * Defines if the translucency is enabled in the material.
  50482. */
  50483. isTranslucencyEnabled: boolean;
  50484. private _isScatteringEnabled;
  50485. /**
  50486. * Defines the refraction intensity of the material.
  50487. * The refraction when enabled replaces the Diffuse part of the material.
  50488. * The intensity helps transitionning between diffuse and refraction.
  50489. */
  50490. refractionIntensity: number;
  50491. /**
  50492. * Defines the translucency intensity of the material.
  50493. * When translucency has been enabled, this defines how much of the "translucency"
  50494. * is addded to the diffuse part of the material.
  50495. */
  50496. translucencyIntensity: number;
  50497. /**
  50498. * Defines the scattering intensity of the material.
  50499. * When scattering has been enabled, this defines how much of the "scattered light"
  50500. * is addded to the diffuse part of the material.
  50501. */
  50502. scatteringIntensity: number;
  50503. private _thicknessTexture;
  50504. /**
  50505. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50506. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50507. * 0 would mean minimumThickness
  50508. * 1 would mean maximumThickness
  50509. * The other channels might be use as a mask to vary the different effects intensity.
  50510. */
  50511. thicknessTexture: Nullable<BaseTexture>;
  50512. private _refractionTexture;
  50513. /**
  50514. * Defines the texture to use for refraction.
  50515. */
  50516. refractionTexture: Nullable<BaseTexture>;
  50517. private _indexOfRefraction;
  50518. /**
  50519. * Defines the index of refraction used in the material.
  50520. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50521. */
  50522. indexOfRefraction: number;
  50523. private _invertRefractionY;
  50524. /**
  50525. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50526. */
  50527. invertRefractionY: boolean;
  50528. private _linkRefractionWithTransparency;
  50529. /**
  50530. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50531. * Materials half opaque for instance using refraction could benefit from this control.
  50532. */
  50533. linkRefractionWithTransparency: boolean;
  50534. /**
  50535. * Defines the minimum thickness stored in the thickness map.
  50536. * If no thickness map is defined, this value will be used to simulate thickness.
  50537. */
  50538. minimumThickness: number;
  50539. /**
  50540. * Defines the maximum thickness stored in the thickness map.
  50541. */
  50542. maximumThickness: number;
  50543. /**
  50544. * Defines the volume tint of the material.
  50545. * This is used for both translucency and scattering.
  50546. */
  50547. tintColor: Color3;
  50548. /**
  50549. * Defines the distance at which the tint color should be found in the media.
  50550. * This is used for refraction only.
  50551. */
  50552. tintColorAtDistance: number;
  50553. /**
  50554. * Defines how far each channel transmit through the media.
  50555. * It is defined as a color to simplify it selection.
  50556. */
  50557. diffusionDistance: Color3;
  50558. private _useMaskFromThicknessTexture;
  50559. /**
  50560. * Stores the intensity of the different subsurface effects in the thickness texture.
  50561. * * the green channel is the translucency intensity.
  50562. * * the blue channel is the scattering intensity.
  50563. * * the alpha channel is the refraction intensity.
  50564. */
  50565. useMaskFromThicknessTexture: boolean;
  50566. /** @hidden */
  50567. private _internalMarkAllSubMeshesAsTexturesDirty;
  50568. /** @hidden */
  50569. _markAllSubMeshesAsTexturesDirty(): void;
  50570. /**
  50571. * Instantiate a new istance of sub surface configuration.
  50572. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50573. */
  50574. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50575. /**
  50576. * Gets wehter the submesh is ready to be used or not.
  50577. * @param defines the list of "defines" to update.
  50578. * @param scene defines the scene the material belongs to.
  50579. * @returns - boolean indicating that the submesh is ready or not.
  50580. */
  50581. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50582. /**
  50583. * Checks to see if a texture is used in the material.
  50584. * @param defines the list of "defines" to update.
  50585. * @param scene defines the scene to the material belongs to.
  50586. */
  50587. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50588. /**
  50589. * Binds the material data.
  50590. * @param uniformBuffer defines the Uniform buffer to fill in.
  50591. * @param scene defines the scene the material belongs to.
  50592. * @param engine defines the engine the material belongs to.
  50593. * @param isFrozen defines wether the material is frozen or not.
  50594. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50595. */
  50596. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50597. /**
  50598. * Unbinds the material from the mesh.
  50599. * @param activeEffect defines the effect that should be unbound from.
  50600. * @returns true if unbound, otherwise false
  50601. */
  50602. unbind(activeEffect: Effect): boolean;
  50603. /**
  50604. * Returns the texture used for refraction or null if none is used.
  50605. * @param scene defines the scene the material belongs to.
  50606. * @returns - Refraction texture if present. If no refraction texture and refraction
  50607. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50608. */
  50609. private _getRefractionTexture;
  50610. /**
  50611. * Returns true if alpha blending should be disabled.
  50612. */
  50613. get disableAlphaBlending(): boolean;
  50614. /**
  50615. * Fills the list of render target textures.
  50616. * @param renderTargets the list of render targets to update
  50617. */
  50618. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50619. /**
  50620. * Checks to see if a texture is used in the material.
  50621. * @param texture - Base texture to use.
  50622. * @returns - Boolean specifying if a texture is used in the material.
  50623. */
  50624. hasTexture(texture: BaseTexture): boolean;
  50625. /**
  50626. * Gets a boolean indicating that current material needs to register RTT
  50627. * @returns true if this uses a render target otherwise false.
  50628. */
  50629. hasRenderTargetTextures(): boolean;
  50630. /**
  50631. * Returns an array of the actively used textures.
  50632. * @param activeTextures Array of BaseTextures
  50633. */
  50634. getActiveTextures(activeTextures: BaseTexture[]): void;
  50635. /**
  50636. * Returns the animatable textures.
  50637. * @param animatables Array of animatable textures.
  50638. */
  50639. getAnimatables(animatables: IAnimatable[]): void;
  50640. /**
  50641. * Disposes the resources of the material.
  50642. * @param forceDisposeTextures - Forces the disposal of all textures.
  50643. */
  50644. dispose(forceDisposeTextures?: boolean): void;
  50645. /**
  50646. * Get the current class name of the texture useful for serialization or dynamic coding.
  50647. * @returns "PBRSubSurfaceConfiguration"
  50648. */
  50649. getClassName(): string;
  50650. /**
  50651. * Add fallbacks to the effect fallbacks list.
  50652. * @param defines defines the Base texture to use.
  50653. * @param fallbacks defines the current fallback list.
  50654. * @param currentRank defines the current fallback rank.
  50655. * @returns the new fallback rank.
  50656. */
  50657. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50658. /**
  50659. * Add the required uniforms to the current list.
  50660. * @param uniforms defines the current uniform list.
  50661. */
  50662. static AddUniforms(uniforms: string[]): void;
  50663. /**
  50664. * Add the required samplers to the current list.
  50665. * @param samplers defines the current sampler list.
  50666. */
  50667. static AddSamplers(samplers: string[]): void;
  50668. /**
  50669. * Add the required uniforms to the current buffer.
  50670. * @param uniformBuffer defines the current uniform buffer.
  50671. */
  50672. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50673. /**
  50674. * Makes a duplicate of the current configuration into another one.
  50675. * @param configuration define the config where to copy the info
  50676. */
  50677. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50678. /**
  50679. * Serializes this Sub Surface configuration.
  50680. * @returns - An object with the serialized config.
  50681. */
  50682. serialize(): any;
  50683. /**
  50684. * Parses a anisotropy Configuration from a serialized object.
  50685. * @param source - Serialized object.
  50686. * @param scene Defines the scene we are parsing for
  50687. * @param rootUrl Defines the rootUrl to load from
  50688. */
  50689. parse(source: any, scene: Scene, rootUrl: string): void;
  50690. }
  50691. }
  50692. declare module BABYLON {
  50693. /** @hidden */
  50694. export var pbrFragmentDeclaration: {
  50695. name: string;
  50696. shader: string;
  50697. };
  50698. }
  50699. declare module BABYLON {
  50700. /** @hidden */
  50701. export var pbrUboDeclaration: {
  50702. name: string;
  50703. shader: string;
  50704. };
  50705. }
  50706. declare module BABYLON {
  50707. /** @hidden */
  50708. export var pbrFragmentExtraDeclaration: {
  50709. name: string;
  50710. shader: string;
  50711. };
  50712. }
  50713. declare module BABYLON {
  50714. /** @hidden */
  50715. export var pbrFragmentSamplersDeclaration: {
  50716. name: string;
  50717. shader: string;
  50718. };
  50719. }
  50720. declare module BABYLON {
  50721. /** @hidden */
  50722. export var pbrHelperFunctions: {
  50723. name: string;
  50724. shader: string;
  50725. };
  50726. }
  50727. declare module BABYLON {
  50728. /** @hidden */
  50729. export var harmonicsFunctions: {
  50730. name: string;
  50731. shader: string;
  50732. };
  50733. }
  50734. declare module BABYLON {
  50735. /** @hidden */
  50736. export var pbrDirectLightingSetupFunctions: {
  50737. name: string;
  50738. shader: string;
  50739. };
  50740. }
  50741. declare module BABYLON {
  50742. /** @hidden */
  50743. export var pbrDirectLightingFalloffFunctions: {
  50744. name: string;
  50745. shader: string;
  50746. };
  50747. }
  50748. declare module BABYLON {
  50749. /** @hidden */
  50750. export var pbrBRDFFunctions: {
  50751. name: string;
  50752. shader: string;
  50753. };
  50754. }
  50755. declare module BABYLON {
  50756. /** @hidden */
  50757. export var pbrDirectLightingFunctions: {
  50758. name: string;
  50759. shader: string;
  50760. };
  50761. }
  50762. declare module BABYLON {
  50763. /** @hidden */
  50764. export var pbrIBLFunctions: {
  50765. name: string;
  50766. shader: string;
  50767. };
  50768. }
  50769. declare module BABYLON {
  50770. /** @hidden */
  50771. export var pbrDebug: {
  50772. name: string;
  50773. shader: string;
  50774. };
  50775. }
  50776. declare module BABYLON {
  50777. /** @hidden */
  50778. export var pbrPixelShader: {
  50779. name: string;
  50780. shader: string;
  50781. };
  50782. }
  50783. declare module BABYLON {
  50784. /** @hidden */
  50785. export var pbrVertexDeclaration: {
  50786. name: string;
  50787. shader: string;
  50788. };
  50789. }
  50790. declare module BABYLON {
  50791. /** @hidden */
  50792. export var pbrVertexShader: {
  50793. name: string;
  50794. shader: string;
  50795. };
  50796. }
  50797. declare module BABYLON {
  50798. /**
  50799. * Manages the defines for the PBR Material.
  50800. * @hidden
  50801. */
  50802. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50803. PBR: boolean;
  50804. MAINUV1: boolean;
  50805. MAINUV2: boolean;
  50806. UV1: boolean;
  50807. UV2: boolean;
  50808. ALBEDO: boolean;
  50809. ALBEDODIRECTUV: number;
  50810. VERTEXCOLOR: boolean;
  50811. AMBIENT: boolean;
  50812. AMBIENTDIRECTUV: number;
  50813. AMBIENTINGRAYSCALE: boolean;
  50814. OPACITY: boolean;
  50815. VERTEXALPHA: boolean;
  50816. OPACITYDIRECTUV: number;
  50817. OPACITYRGB: boolean;
  50818. ALPHATEST: boolean;
  50819. DEPTHPREPASS: boolean;
  50820. ALPHABLEND: boolean;
  50821. ALPHAFROMALBEDO: boolean;
  50822. ALPHATESTVALUE: string;
  50823. SPECULAROVERALPHA: boolean;
  50824. RADIANCEOVERALPHA: boolean;
  50825. ALPHAFRESNEL: boolean;
  50826. LINEARALPHAFRESNEL: boolean;
  50827. PREMULTIPLYALPHA: boolean;
  50828. EMISSIVE: boolean;
  50829. EMISSIVEDIRECTUV: number;
  50830. REFLECTIVITY: boolean;
  50831. REFLECTIVITYDIRECTUV: number;
  50832. SPECULARTERM: boolean;
  50833. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50834. MICROSURFACEAUTOMATIC: boolean;
  50835. LODBASEDMICROSFURACE: boolean;
  50836. MICROSURFACEMAP: boolean;
  50837. MICROSURFACEMAPDIRECTUV: number;
  50838. METALLICWORKFLOW: boolean;
  50839. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50840. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50841. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50842. AOSTOREINMETALMAPRED: boolean;
  50843. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50844. ENVIRONMENTBRDF: boolean;
  50845. ENVIRONMENTBRDF_RGBD: boolean;
  50846. NORMAL: boolean;
  50847. TANGENT: boolean;
  50848. BUMP: boolean;
  50849. BUMPDIRECTUV: number;
  50850. OBJECTSPACE_NORMALMAP: boolean;
  50851. PARALLAX: boolean;
  50852. PARALLAXOCCLUSION: boolean;
  50853. NORMALXYSCALE: boolean;
  50854. LIGHTMAP: boolean;
  50855. LIGHTMAPDIRECTUV: number;
  50856. USELIGHTMAPASSHADOWMAP: boolean;
  50857. GAMMALIGHTMAP: boolean;
  50858. RGBDLIGHTMAP: boolean;
  50859. REFLECTION: boolean;
  50860. REFLECTIONMAP_3D: boolean;
  50861. REFLECTIONMAP_SPHERICAL: boolean;
  50862. REFLECTIONMAP_PLANAR: boolean;
  50863. REFLECTIONMAP_CUBIC: boolean;
  50864. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50865. REFLECTIONMAP_PROJECTION: boolean;
  50866. REFLECTIONMAP_SKYBOX: boolean;
  50867. REFLECTIONMAP_EXPLICIT: boolean;
  50868. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50869. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50870. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50871. INVERTCUBICMAP: boolean;
  50872. USESPHERICALFROMREFLECTIONMAP: boolean;
  50873. USEIRRADIANCEMAP: boolean;
  50874. SPHERICAL_HARMONICS: boolean;
  50875. USESPHERICALINVERTEX: boolean;
  50876. REFLECTIONMAP_OPPOSITEZ: boolean;
  50877. LODINREFLECTIONALPHA: boolean;
  50878. GAMMAREFLECTION: boolean;
  50879. RGBDREFLECTION: boolean;
  50880. LINEARSPECULARREFLECTION: boolean;
  50881. RADIANCEOCCLUSION: boolean;
  50882. HORIZONOCCLUSION: boolean;
  50883. INSTANCES: boolean;
  50884. NUM_BONE_INFLUENCERS: number;
  50885. BonesPerMesh: number;
  50886. BONETEXTURE: boolean;
  50887. NONUNIFORMSCALING: boolean;
  50888. MORPHTARGETS: boolean;
  50889. MORPHTARGETS_NORMAL: boolean;
  50890. MORPHTARGETS_TANGENT: boolean;
  50891. MORPHTARGETS_UV: boolean;
  50892. NUM_MORPH_INFLUENCERS: number;
  50893. IMAGEPROCESSING: boolean;
  50894. VIGNETTE: boolean;
  50895. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50896. VIGNETTEBLENDMODEOPAQUE: boolean;
  50897. TONEMAPPING: boolean;
  50898. TONEMAPPING_ACES: boolean;
  50899. CONTRAST: boolean;
  50900. COLORCURVES: boolean;
  50901. COLORGRADING: boolean;
  50902. COLORGRADING3D: boolean;
  50903. SAMPLER3DGREENDEPTH: boolean;
  50904. SAMPLER3DBGRMAP: boolean;
  50905. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50906. EXPOSURE: boolean;
  50907. MULTIVIEW: boolean;
  50908. USEPHYSICALLIGHTFALLOFF: boolean;
  50909. USEGLTFLIGHTFALLOFF: boolean;
  50910. TWOSIDEDLIGHTING: boolean;
  50911. SHADOWFLOAT: boolean;
  50912. CLIPPLANE: boolean;
  50913. CLIPPLANE2: boolean;
  50914. CLIPPLANE3: boolean;
  50915. CLIPPLANE4: boolean;
  50916. CLIPPLANE5: boolean;
  50917. CLIPPLANE6: boolean;
  50918. POINTSIZE: boolean;
  50919. FOG: boolean;
  50920. LOGARITHMICDEPTH: boolean;
  50921. FORCENORMALFORWARD: boolean;
  50922. SPECULARAA: boolean;
  50923. CLEARCOAT: boolean;
  50924. CLEARCOAT_DEFAULTIOR: boolean;
  50925. CLEARCOAT_TEXTURE: boolean;
  50926. CLEARCOAT_TEXTUREDIRECTUV: number;
  50927. CLEARCOAT_BUMP: boolean;
  50928. CLEARCOAT_BUMPDIRECTUV: number;
  50929. CLEARCOAT_TINT: boolean;
  50930. CLEARCOAT_TINT_TEXTURE: boolean;
  50931. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50932. ANISOTROPIC: boolean;
  50933. ANISOTROPIC_TEXTURE: boolean;
  50934. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50935. BRDF_V_HEIGHT_CORRELATED: boolean;
  50936. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50937. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50938. SHEEN: boolean;
  50939. SHEEN_TEXTURE: boolean;
  50940. SHEEN_TEXTUREDIRECTUV: number;
  50941. SHEEN_LINKWITHALBEDO: boolean;
  50942. SUBSURFACE: boolean;
  50943. SS_REFRACTION: boolean;
  50944. SS_TRANSLUCENCY: boolean;
  50945. SS_SCATERRING: boolean;
  50946. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50947. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50948. SS_REFRACTIONMAP_3D: boolean;
  50949. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50950. SS_LODINREFRACTIONALPHA: boolean;
  50951. SS_GAMMAREFRACTION: boolean;
  50952. SS_RGBDREFRACTION: boolean;
  50953. SS_LINEARSPECULARREFRACTION: boolean;
  50954. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50955. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50956. UNLIT: boolean;
  50957. DEBUGMODE: number;
  50958. /**
  50959. * Initializes the PBR Material defines.
  50960. */
  50961. constructor();
  50962. /**
  50963. * Resets the PBR Material defines.
  50964. */
  50965. reset(): void;
  50966. }
  50967. /**
  50968. * The Physically based material base class of BJS.
  50969. *
  50970. * This offers the main features of a standard PBR material.
  50971. * For more information, please refer to the documentation :
  50972. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50973. */
  50974. export abstract class PBRBaseMaterial extends PushMaterial {
  50975. /**
  50976. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50977. */
  50978. static readonly PBRMATERIAL_OPAQUE: number;
  50979. /**
  50980. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50981. */
  50982. static readonly PBRMATERIAL_ALPHATEST: number;
  50983. /**
  50984. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50985. */
  50986. static readonly PBRMATERIAL_ALPHABLEND: number;
  50987. /**
  50988. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50989. * They are also discarded below the alpha cutoff threshold to improve performances.
  50990. */
  50991. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50992. /**
  50993. * Defines the default value of how much AO map is occluding the analytical lights
  50994. * (point spot...).
  50995. */
  50996. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50997. /**
  50998. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50999. */
  51000. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51001. /**
  51002. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51003. * to enhance interoperability with other engines.
  51004. */
  51005. static readonly LIGHTFALLOFF_GLTF: number;
  51006. /**
  51007. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51008. * to enhance interoperability with other materials.
  51009. */
  51010. static readonly LIGHTFALLOFF_STANDARD: number;
  51011. /**
  51012. * Intensity of the direct lights e.g. the four lights available in your scene.
  51013. * This impacts both the direct diffuse and specular highlights.
  51014. */
  51015. protected _directIntensity: number;
  51016. /**
  51017. * Intensity of the emissive part of the material.
  51018. * This helps controlling the emissive effect without modifying the emissive color.
  51019. */
  51020. protected _emissiveIntensity: number;
  51021. /**
  51022. * Intensity of the environment e.g. how much the environment will light the object
  51023. * either through harmonics for rough material or through the refelction for shiny ones.
  51024. */
  51025. protected _environmentIntensity: number;
  51026. /**
  51027. * This is a special control allowing the reduction of the specular highlights coming from the
  51028. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51029. */
  51030. protected _specularIntensity: number;
  51031. /**
  51032. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51033. */
  51034. private _lightingInfos;
  51035. /**
  51036. * Debug Control allowing disabling the bump map on this material.
  51037. */
  51038. protected _disableBumpMap: boolean;
  51039. /**
  51040. * AKA Diffuse Texture in standard nomenclature.
  51041. */
  51042. protected _albedoTexture: Nullable<BaseTexture>;
  51043. /**
  51044. * AKA Occlusion Texture in other nomenclature.
  51045. */
  51046. protected _ambientTexture: Nullable<BaseTexture>;
  51047. /**
  51048. * AKA Occlusion Texture Intensity in other nomenclature.
  51049. */
  51050. protected _ambientTextureStrength: number;
  51051. /**
  51052. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51053. * 1 means it completely occludes it
  51054. * 0 mean it has no impact
  51055. */
  51056. protected _ambientTextureImpactOnAnalyticalLights: number;
  51057. /**
  51058. * Stores the alpha values in a texture.
  51059. */
  51060. protected _opacityTexture: Nullable<BaseTexture>;
  51061. /**
  51062. * Stores the reflection values in a texture.
  51063. */
  51064. protected _reflectionTexture: Nullable<BaseTexture>;
  51065. /**
  51066. * Stores the emissive values in a texture.
  51067. */
  51068. protected _emissiveTexture: Nullable<BaseTexture>;
  51069. /**
  51070. * AKA Specular texture in other nomenclature.
  51071. */
  51072. protected _reflectivityTexture: Nullable<BaseTexture>;
  51073. /**
  51074. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51075. */
  51076. protected _metallicTexture: Nullable<BaseTexture>;
  51077. /**
  51078. * Specifies the metallic scalar of the metallic/roughness workflow.
  51079. * Can also be used to scale the metalness values of the metallic texture.
  51080. */
  51081. protected _metallic: Nullable<number>;
  51082. /**
  51083. * Specifies the roughness scalar of the metallic/roughness workflow.
  51084. * Can also be used to scale the roughness values of the metallic texture.
  51085. */
  51086. protected _roughness: Nullable<number>;
  51087. /**
  51088. * Specifies the an F0 factor to help configuring the material F0.
  51089. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51090. * to 0.5 the previously hard coded value stays the same.
  51091. * Can also be used to scale the F0 values of the metallic texture.
  51092. */
  51093. protected _metallicF0Factor: number;
  51094. /**
  51095. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51096. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51097. * your expectation as it multiplies with the texture data.
  51098. */
  51099. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51100. /**
  51101. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51102. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51103. */
  51104. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51105. /**
  51106. * Stores surface normal data used to displace a mesh in a texture.
  51107. */
  51108. protected _bumpTexture: Nullable<BaseTexture>;
  51109. /**
  51110. * Stores the pre-calculated light information of a mesh in a texture.
  51111. */
  51112. protected _lightmapTexture: Nullable<BaseTexture>;
  51113. /**
  51114. * The color of a material in ambient lighting.
  51115. */
  51116. protected _ambientColor: Color3;
  51117. /**
  51118. * AKA Diffuse Color in other nomenclature.
  51119. */
  51120. protected _albedoColor: Color3;
  51121. /**
  51122. * AKA Specular Color in other nomenclature.
  51123. */
  51124. protected _reflectivityColor: Color3;
  51125. /**
  51126. * The color applied when light is reflected from a material.
  51127. */
  51128. protected _reflectionColor: Color3;
  51129. /**
  51130. * The color applied when light is emitted from a material.
  51131. */
  51132. protected _emissiveColor: Color3;
  51133. /**
  51134. * AKA Glossiness in other nomenclature.
  51135. */
  51136. protected _microSurface: number;
  51137. /**
  51138. * Specifies that the material will use the light map as a show map.
  51139. */
  51140. protected _useLightmapAsShadowmap: boolean;
  51141. /**
  51142. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51143. * makes the reflect vector face the model (under horizon).
  51144. */
  51145. protected _useHorizonOcclusion: boolean;
  51146. /**
  51147. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51148. * too much the area relying on ambient texture to define their ambient occlusion.
  51149. */
  51150. protected _useRadianceOcclusion: boolean;
  51151. /**
  51152. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51153. */
  51154. protected _useAlphaFromAlbedoTexture: boolean;
  51155. /**
  51156. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51157. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51158. */
  51159. protected _useSpecularOverAlpha: boolean;
  51160. /**
  51161. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51162. */
  51163. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51164. /**
  51165. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51166. */
  51167. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51168. /**
  51169. * Specifies if the metallic texture contains the roughness information in its green channel.
  51170. */
  51171. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51172. /**
  51173. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51174. */
  51175. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51176. /**
  51177. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51178. */
  51179. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51180. /**
  51181. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51182. */
  51183. protected _useAmbientInGrayScale: boolean;
  51184. /**
  51185. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51186. * The material will try to infer what glossiness each pixel should be.
  51187. */
  51188. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51189. /**
  51190. * Defines the falloff type used in this material.
  51191. * It by default is Physical.
  51192. */
  51193. protected _lightFalloff: number;
  51194. /**
  51195. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51196. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51197. */
  51198. protected _useRadianceOverAlpha: boolean;
  51199. /**
  51200. * Allows using an object space normal map (instead of tangent space).
  51201. */
  51202. protected _useObjectSpaceNormalMap: boolean;
  51203. /**
  51204. * Allows using the bump map in parallax mode.
  51205. */
  51206. protected _useParallax: boolean;
  51207. /**
  51208. * Allows using the bump map in parallax occlusion mode.
  51209. */
  51210. protected _useParallaxOcclusion: boolean;
  51211. /**
  51212. * Controls the scale bias of the parallax mode.
  51213. */
  51214. protected _parallaxScaleBias: number;
  51215. /**
  51216. * If sets to true, disables all the lights affecting the material.
  51217. */
  51218. protected _disableLighting: boolean;
  51219. /**
  51220. * Number of Simultaneous lights allowed on the material.
  51221. */
  51222. protected _maxSimultaneousLights: number;
  51223. /**
  51224. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51225. */
  51226. protected _invertNormalMapX: boolean;
  51227. /**
  51228. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51229. */
  51230. protected _invertNormalMapY: boolean;
  51231. /**
  51232. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51233. */
  51234. protected _twoSidedLighting: boolean;
  51235. /**
  51236. * Defines the alpha limits in alpha test mode.
  51237. */
  51238. protected _alphaCutOff: number;
  51239. /**
  51240. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51241. */
  51242. protected _forceAlphaTest: boolean;
  51243. /**
  51244. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51245. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51246. */
  51247. protected _useAlphaFresnel: boolean;
  51248. /**
  51249. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51250. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51251. */
  51252. protected _useLinearAlphaFresnel: boolean;
  51253. /**
  51254. * The transparency mode of the material.
  51255. */
  51256. protected _transparencyMode: Nullable<number>;
  51257. /**
  51258. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51259. * from cos thetav and roughness:
  51260. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51261. */
  51262. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51263. /**
  51264. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51265. */
  51266. protected _forceIrradianceInFragment: boolean;
  51267. /**
  51268. * Force normal to face away from face.
  51269. */
  51270. protected _forceNormalForward: boolean;
  51271. /**
  51272. * Enables specular anti aliasing in the PBR shader.
  51273. * It will both interacts on the Geometry for analytical and IBL lighting.
  51274. * It also prefilter the roughness map based on the bump values.
  51275. */
  51276. protected _enableSpecularAntiAliasing: boolean;
  51277. /**
  51278. * Default configuration related to image processing available in the PBR Material.
  51279. */
  51280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51281. /**
  51282. * Keep track of the image processing observer to allow dispose and replace.
  51283. */
  51284. private _imageProcessingObserver;
  51285. /**
  51286. * Attaches a new image processing configuration to the PBR Material.
  51287. * @param configuration
  51288. */
  51289. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51290. /**
  51291. * Stores the available render targets.
  51292. */
  51293. private _renderTargets;
  51294. /**
  51295. * Sets the global ambient color for the material used in lighting calculations.
  51296. */
  51297. private _globalAmbientColor;
  51298. /**
  51299. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51300. */
  51301. private _useLogarithmicDepth;
  51302. /**
  51303. * If set to true, no lighting calculations will be applied.
  51304. */
  51305. private _unlit;
  51306. private _debugMode;
  51307. /**
  51308. * @hidden
  51309. * This is reserved for the inspector.
  51310. * Defines the material debug mode.
  51311. * It helps seeing only some components of the material while troubleshooting.
  51312. */
  51313. debugMode: number;
  51314. /**
  51315. * @hidden
  51316. * This is reserved for the inspector.
  51317. * Specify from where on screen the debug mode should start.
  51318. * The value goes from -1 (full screen) to 1 (not visible)
  51319. * It helps with side by side comparison against the final render
  51320. * This defaults to -1
  51321. */
  51322. private debugLimit;
  51323. /**
  51324. * @hidden
  51325. * This is reserved for the inspector.
  51326. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51327. * You can use the factor to better multiply the final value.
  51328. */
  51329. private debugFactor;
  51330. /**
  51331. * Defines the clear coat layer parameters for the material.
  51332. */
  51333. readonly clearCoat: PBRClearCoatConfiguration;
  51334. /**
  51335. * Defines the anisotropic parameters for the material.
  51336. */
  51337. readonly anisotropy: PBRAnisotropicConfiguration;
  51338. /**
  51339. * Defines the BRDF parameters for the material.
  51340. */
  51341. readonly brdf: PBRBRDFConfiguration;
  51342. /**
  51343. * Defines the Sheen parameters for the material.
  51344. */
  51345. readonly sheen: PBRSheenConfiguration;
  51346. /**
  51347. * Defines the SubSurface parameters for the material.
  51348. */
  51349. readonly subSurface: PBRSubSurfaceConfiguration;
  51350. /**
  51351. * Custom callback helping to override the default shader used in the material.
  51352. */
  51353. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51354. protected _rebuildInParallel: boolean;
  51355. /**
  51356. * Instantiates a new PBRMaterial instance.
  51357. *
  51358. * @param name The material name
  51359. * @param scene The scene the material will be use in.
  51360. */
  51361. constructor(name: string, scene: Scene);
  51362. /**
  51363. * Gets a boolean indicating that current material needs to register RTT
  51364. */
  51365. get hasRenderTargetTextures(): boolean;
  51366. /**
  51367. * Gets the name of the material class.
  51368. */
  51369. getClassName(): string;
  51370. /**
  51371. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51372. */
  51373. get useLogarithmicDepth(): boolean;
  51374. /**
  51375. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51376. */
  51377. set useLogarithmicDepth(value: boolean);
  51378. /**
  51379. * Gets the current transparency mode.
  51380. */
  51381. get transparencyMode(): Nullable<number>;
  51382. /**
  51383. * Sets the transparency mode of the material.
  51384. *
  51385. * | Value | Type | Description |
  51386. * | ----- | ----------------------------------- | ----------- |
  51387. * | 0 | OPAQUE | |
  51388. * | 1 | ALPHATEST | |
  51389. * | 2 | ALPHABLEND | |
  51390. * | 3 | ALPHATESTANDBLEND | |
  51391. *
  51392. */
  51393. set transparencyMode(value: Nullable<number>);
  51394. /**
  51395. * Returns true if alpha blending should be disabled.
  51396. */
  51397. private get _disableAlphaBlending();
  51398. /**
  51399. * Specifies whether or not this material should be rendered in alpha blend mode.
  51400. */
  51401. needAlphaBlending(): boolean;
  51402. /**
  51403. * Specifies if the mesh will require alpha blending.
  51404. * @param mesh - BJS mesh.
  51405. */
  51406. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51407. /**
  51408. * Specifies whether or not this material should be rendered in alpha test mode.
  51409. */
  51410. needAlphaTesting(): boolean;
  51411. /**
  51412. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51413. */
  51414. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51415. /**
  51416. * Gets the texture used for the alpha test.
  51417. */
  51418. getAlphaTestTexture(): Nullable<BaseTexture>;
  51419. /**
  51420. * Specifies that the submesh is ready to be used.
  51421. * @param mesh - BJS mesh.
  51422. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51423. * @param useInstances - Specifies that instances should be used.
  51424. * @returns - boolean indicating that the submesh is ready or not.
  51425. */
  51426. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51427. /**
  51428. * Specifies if the material uses metallic roughness workflow.
  51429. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51430. */
  51431. isMetallicWorkflow(): boolean;
  51432. private _prepareEffect;
  51433. private _prepareDefines;
  51434. /**
  51435. * Force shader compilation
  51436. */
  51437. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51438. /**
  51439. * Initializes the uniform buffer layout for the shader.
  51440. */
  51441. buildUniformLayout(): void;
  51442. /**
  51443. * Unbinds the material from the mesh
  51444. */
  51445. unbind(): void;
  51446. /**
  51447. * Binds the submesh data.
  51448. * @param world - The world matrix.
  51449. * @param mesh - The BJS mesh.
  51450. * @param subMesh - A submesh of the BJS mesh.
  51451. */
  51452. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51453. /**
  51454. * Returns the animatable textures.
  51455. * @returns - Array of animatable textures.
  51456. */
  51457. getAnimatables(): IAnimatable[];
  51458. /**
  51459. * Returns the texture used for reflections.
  51460. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51461. */
  51462. private _getReflectionTexture;
  51463. /**
  51464. * Returns an array of the actively used textures.
  51465. * @returns - Array of BaseTextures
  51466. */
  51467. getActiveTextures(): BaseTexture[];
  51468. /**
  51469. * Checks to see if a texture is used in the material.
  51470. * @param texture - Base texture to use.
  51471. * @returns - Boolean specifying if a texture is used in the material.
  51472. */
  51473. hasTexture(texture: BaseTexture): boolean;
  51474. /**
  51475. * Disposes the resources of the material.
  51476. * @param forceDisposeEffect - Forces the disposal of effects.
  51477. * @param forceDisposeTextures - Forces the disposal of all textures.
  51478. */
  51479. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51480. }
  51481. }
  51482. declare module BABYLON {
  51483. /**
  51484. * The Physically based material of BJS.
  51485. *
  51486. * This offers the main features of a standard PBR material.
  51487. * For more information, please refer to the documentation :
  51488. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51489. */
  51490. export class PBRMaterial extends PBRBaseMaterial {
  51491. /**
  51492. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51493. */
  51494. static readonly PBRMATERIAL_OPAQUE: number;
  51495. /**
  51496. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51497. */
  51498. static readonly PBRMATERIAL_ALPHATEST: number;
  51499. /**
  51500. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51501. */
  51502. static readonly PBRMATERIAL_ALPHABLEND: number;
  51503. /**
  51504. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51505. * They are also discarded below the alpha cutoff threshold to improve performances.
  51506. */
  51507. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51508. /**
  51509. * Defines the default value of how much AO map is occluding the analytical lights
  51510. * (point spot...).
  51511. */
  51512. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51513. /**
  51514. * Intensity of the direct lights e.g. the four lights available in your scene.
  51515. * This impacts both the direct diffuse and specular highlights.
  51516. */
  51517. directIntensity: number;
  51518. /**
  51519. * Intensity of the emissive part of the material.
  51520. * This helps controlling the emissive effect without modifying the emissive color.
  51521. */
  51522. emissiveIntensity: number;
  51523. /**
  51524. * Intensity of the environment e.g. how much the environment will light the object
  51525. * either through harmonics for rough material or through the refelction for shiny ones.
  51526. */
  51527. environmentIntensity: number;
  51528. /**
  51529. * This is a special control allowing the reduction of the specular highlights coming from the
  51530. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51531. */
  51532. specularIntensity: number;
  51533. /**
  51534. * Debug Control allowing disabling the bump map on this material.
  51535. */
  51536. disableBumpMap: boolean;
  51537. /**
  51538. * AKA Diffuse Texture in standard nomenclature.
  51539. */
  51540. albedoTexture: BaseTexture;
  51541. /**
  51542. * AKA Occlusion Texture in other nomenclature.
  51543. */
  51544. ambientTexture: BaseTexture;
  51545. /**
  51546. * AKA Occlusion Texture Intensity in other nomenclature.
  51547. */
  51548. ambientTextureStrength: number;
  51549. /**
  51550. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51551. * 1 means it completely occludes it
  51552. * 0 mean it has no impact
  51553. */
  51554. ambientTextureImpactOnAnalyticalLights: number;
  51555. /**
  51556. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51557. */
  51558. opacityTexture: BaseTexture;
  51559. /**
  51560. * Stores the reflection values in a texture.
  51561. */
  51562. reflectionTexture: Nullable<BaseTexture>;
  51563. /**
  51564. * Stores the emissive values in a texture.
  51565. */
  51566. emissiveTexture: BaseTexture;
  51567. /**
  51568. * AKA Specular texture in other nomenclature.
  51569. */
  51570. reflectivityTexture: BaseTexture;
  51571. /**
  51572. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51573. */
  51574. metallicTexture: BaseTexture;
  51575. /**
  51576. * Specifies the metallic scalar of the metallic/roughness workflow.
  51577. * Can also be used to scale the metalness values of the metallic texture.
  51578. */
  51579. metallic: Nullable<number>;
  51580. /**
  51581. * Specifies the roughness scalar of the metallic/roughness workflow.
  51582. * Can also be used to scale the roughness values of the metallic texture.
  51583. */
  51584. roughness: Nullable<number>;
  51585. /**
  51586. * Specifies the an F0 factor to help configuring the material F0.
  51587. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51588. * to 0.5 the previously hard coded value stays the same.
  51589. * Can also be used to scale the F0 values of the metallic texture.
  51590. */
  51591. metallicF0Factor: number;
  51592. /**
  51593. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51594. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51595. * your expectation as it multiplies with the texture data.
  51596. */
  51597. useMetallicF0FactorFromMetallicTexture: boolean;
  51598. /**
  51599. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51600. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51601. */
  51602. microSurfaceTexture: BaseTexture;
  51603. /**
  51604. * Stores surface normal data used to displace a mesh in a texture.
  51605. */
  51606. bumpTexture: BaseTexture;
  51607. /**
  51608. * Stores the pre-calculated light information of a mesh in a texture.
  51609. */
  51610. lightmapTexture: BaseTexture;
  51611. /**
  51612. * Stores the refracted light information in a texture.
  51613. */
  51614. get refractionTexture(): Nullable<BaseTexture>;
  51615. set refractionTexture(value: Nullable<BaseTexture>);
  51616. /**
  51617. * The color of a material in ambient lighting.
  51618. */
  51619. ambientColor: Color3;
  51620. /**
  51621. * AKA Diffuse Color in other nomenclature.
  51622. */
  51623. albedoColor: Color3;
  51624. /**
  51625. * AKA Specular Color in other nomenclature.
  51626. */
  51627. reflectivityColor: Color3;
  51628. /**
  51629. * The color reflected from the material.
  51630. */
  51631. reflectionColor: Color3;
  51632. /**
  51633. * The color emitted from the material.
  51634. */
  51635. emissiveColor: Color3;
  51636. /**
  51637. * AKA Glossiness in other nomenclature.
  51638. */
  51639. microSurface: number;
  51640. /**
  51641. * source material index of refraction (IOR)' / 'destination material IOR.
  51642. */
  51643. get indexOfRefraction(): number;
  51644. set indexOfRefraction(value: number);
  51645. /**
  51646. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51647. */
  51648. get invertRefractionY(): boolean;
  51649. set invertRefractionY(value: boolean);
  51650. /**
  51651. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51652. * Materials half opaque for instance using refraction could benefit from this control.
  51653. */
  51654. get linkRefractionWithTransparency(): boolean;
  51655. set linkRefractionWithTransparency(value: boolean);
  51656. /**
  51657. * If true, the light map contains occlusion information instead of lighting info.
  51658. */
  51659. useLightmapAsShadowmap: boolean;
  51660. /**
  51661. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51662. */
  51663. useAlphaFromAlbedoTexture: boolean;
  51664. /**
  51665. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51666. */
  51667. forceAlphaTest: boolean;
  51668. /**
  51669. * Defines the alpha limits in alpha test mode.
  51670. */
  51671. alphaCutOff: number;
  51672. /**
  51673. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51674. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51675. */
  51676. useSpecularOverAlpha: boolean;
  51677. /**
  51678. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51679. */
  51680. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51681. /**
  51682. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51683. */
  51684. useRoughnessFromMetallicTextureAlpha: boolean;
  51685. /**
  51686. * Specifies if the metallic texture contains the roughness information in its green channel.
  51687. */
  51688. useRoughnessFromMetallicTextureGreen: boolean;
  51689. /**
  51690. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51691. */
  51692. useMetallnessFromMetallicTextureBlue: boolean;
  51693. /**
  51694. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51695. */
  51696. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51697. /**
  51698. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51699. */
  51700. useAmbientInGrayScale: boolean;
  51701. /**
  51702. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51703. * The material will try to infer what glossiness each pixel should be.
  51704. */
  51705. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51706. /**
  51707. * BJS is using an harcoded light falloff based on a manually sets up range.
  51708. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51709. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51710. */
  51711. get usePhysicalLightFalloff(): boolean;
  51712. /**
  51713. * BJS is using an harcoded light falloff based on a manually sets up range.
  51714. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51715. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51716. */
  51717. set usePhysicalLightFalloff(value: boolean);
  51718. /**
  51719. * In order to support the falloff compatibility with gltf, a special mode has been added
  51720. * to reproduce the gltf light falloff.
  51721. */
  51722. get useGLTFLightFalloff(): boolean;
  51723. /**
  51724. * In order to support the falloff compatibility with gltf, a special mode has been added
  51725. * to reproduce the gltf light falloff.
  51726. */
  51727. set useGLTFLightFalloff(value: boolean);
  51728. /**
  51729. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51730. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51731. */
  51732. useRadianceOverAlpha: boolean;
  51733. /**
  51734. * Allows using an object space normal map (instead of tangent space).
  51735. */
  51736. useObjectSpaceNormalMap: boolean;
  51737. /**
  51738. * Allows using the bump map in parallax mode.
  51739. */
  51740. useParallax: boolean;
  51741. /**
  51742. * Allows using the bump map in parallax occlusion mode.
  51743. */
  51744. useParallaxOcclusion: boolean;
  51745. /**
  51746. * Controls the scale bias of the parallax mode.
  51747. */
  51748. parallaxScaleBias: number;
  51749. /**
  51750. * If sets to true, disables all the lights affecting the material.
  51751. */
  51752. disableLighting: boolean;
  51753. /**
  51754. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51755. */
  51756. forceIrradianceInFragment: boolean;
  51757. /**
  51758. * Number of Simultaneous lights allowed on the material.
  51759. */
  51760. maxSimultaneousLights: number;
  51761. /**
  51762. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51763. */
  51764. invertNormalMapX: boolean;
  51765. /**
  51766. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51767. */
  51768. invertNormalMapY: boolean;
  51769. /**
  51770. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51771. */
  51772. twoSidedLighting: boolean;
  51773. /**
  51774. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51775. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51776. */
  51777. useAlphaFresnel: boolean;
  51778. /**
  51779. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51780. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51781. */
  51782. useLinearAlphaFresnel: boolean;
  51783. /**
  51784. * Let user defines the brdf lookup texture used for IBL.
  51785. * A default 8bit version is embedded but you could point at :
  51786. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51787. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51788. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51789. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51790. */
  51791. environmentBRDFTexture: Nullable<BaseTexture>;
  51792. /**
  51793. * Force normal to face away from face.
  51794. */
  51795. forceNormalForward: boolean;
  51796. /**
  51797. * Enables specular anti aliasing in the PBR shader.
  51798. * It will both interacts on the Geometry for analytical and IBL lighting.
  51799. * It also prefilter the roughness map based on the bump values.
  51800. */
  51801. enableSpecularAntiAliasing: boolean;
  51802. /**
  51803. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51804. * makes the reflect vector face the model (under horizon).
  51805. */
  51806. useHorizonOcclusion: boolean;
  51807. /**
  51808. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51809. * too much the area relying on ambient texture to define their ambient occlusion.
  51810. */
  51811. useRadianceOcclusion: boolean;
  51812. /**
  51813. * If set to true, no lighting calculations will be applied.
  51814. */
  51815. unlit: boolean;
  51816. /**
  51817. * Gets the image processing configuration used either in this material.
  51818. */
  51819. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51820. /**
  51821. * Sets the Default image processing configuration used either in the this material.
  51822. *
  51823. * If sets to null, the scene one is in use.
  51824. */
  51825. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51826. /**
  51827. * Gets wether the color curves effect is enabled.
  51828. */
  51829. get cameraColorCurvesEnabled(): boolean;
  51830. /**
  51831. * Sets wether the color curves effect is enabled.
  51832. */
  51833. set cameraColorCurvesEnabled(value: boolean);
  51834. /**
  51835. * Gets wether the color grading effect is enabled.
  51836. */
  51837. get cameraColorGradingEnabled(): boolean;
  51838. /**
  51839. * Gets wether the color grading effect is enabled.
  51840. */
  51841. set cameraColorGradingEnabled(value: boolean);
  51842. /**
  51843. * Gets wether tonemapping is enabled or not.
  51844. */
  51845. get cameraToneMappingEnabled(): boolean;
  51846. /**
  51847. * Sets wether tonemapping is enabled or not
  51848. */
  51849. set cameraToneMappingEnabled(value: boolean);
  51850. /**
  51851. * The camera exposure used on this material.
  51852. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51853. * This corresponds to a photographic exposure.
  51854. */
  51855. get cameraExposure(): number;
  51856. /**
  51857. * The camera exposure used on this material.
  51858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51859. * This corresponds to a photographic exposure.
  51860. */
  51861. set cameraExposure(value: number);
  51862. /**
  51863. * Gets The camera contrast used on this material.
  51864. */
  51865. get cameraContrast(): number;
  51866. /**
  51867. * Sets The camera contrast used on this material.
  51868. */
  51869. set cameraContrast(value: number);
  51870. /**
  51871. * Gets the Color Grading 2D Lookup Texture.
  51872. */
  51873. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51874. /**
  51875. * Sets the Color Grading 2D Lookup Texture.
  51876. */
  51877. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51878. /**
  51879. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51880. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51881. * 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;
  51882. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51883. */
  51884. get cameraColorCurves(): Nullable<ColorCurves>;
  51885. /**
  51886. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51887. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51888. * 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;
  51889. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51890. */
  51891. set cameraColorCurves(value: Nullable<ColorCurves>);
  51892. /**
  51893. * Instantiates a new PBRMaterial instance.
  51894. *
  51895. * @param name The material name
  51896. * @param scene The scene the material will be use in.
  51897. */
  51898. constructor(name: string, scene: Scene);
  51899. /**
  51900. * Returns the name of this material class.
  51901. */
  51902. getClassName(): string;
  51903. /**
  51904. * Makes a duplicate of the current material.
  51905. * @param name - name to use for the new material.
  51906. */
  51907. clone(name: string): PBRMaterial;
  51908. /**
  51909. * Serializes this PBR Material.
  51910. * @returns - An object with the serialized material.
  51911. */
  51912. serialize(): any;
  51913. /**
  51914. * Parses a PBR Material from a serialized object.
  51915. * @param source - Serialized object.
  51916. * @param scene - BJS scene instance.
  51917. * @param rootUrl - url for the scene object
  51918. * @returns - PBRMaterial
  51919. */
  51920. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51921. }
  51922. }
  51923. declare module BABYLON {
  51924. /**
  51925. * Direct draw surface info
  51926. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51927. */
  51928. export interface DDSInfo {
  51929. /**
  51930. * Width of the texture
  51931. */
  51932. width: number;
  51933. /**
  51934. * Width of the texture
  51935. */
  51936. height: number;
  51937. /**
  51938. * Number of Mipmaps for the texture
  51939. * @see https://en.wikipedia.org/wiki/Mipmap
  51940. */
  51941. mipmapCount: number;
  51942. /**
  51943. * If the textures format is a known fourCC format
  51944. * @see https://www.fourcc.org/
  51945. */
  51946. isFourCC: boolean;
  51947. /**
  51948. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51949. */
  51950. isRGB: boolean;
  51951. /**
  51952. * If the texture is a lumincance format
  51953. */
  51954. isLuminance: boolean;
  51955. /**
  51956. * If this is a cube texture
  51957. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51958. */
  51959. isCube: boolean;
  51960. /**
  51961. * If the texture is a compressed format eg. FOURCC_DXT1
  51962. */
  51963. isCompressed: boolean;
  51964. /**
  51965. * The dxgiFormat of the texture
  51966. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51967. */
  51968. dxgiFormat: number;
  51969. /**
  51970. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51971. */
  51972. textureType: number;
  51973. /**
  51974. * Sphericle polynomial created for the dds texture
  51975. */
  51976. sphericalPolynomial?: SphericalPolynomial;
  51977. }
  51978. /**
  51979. * Class used to provide DDS decompression tools
  51980. */
  51981. export class DDSTools {
  51982. /**
  51983. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51984. */
  51985. static StoreLODInAlphaChannel: boolean;
  51986. /**
  51987. * Gets DDS information from an array buffer
  51988. * @param data defines the array buffer view to read data from
  51989. * @returns the DDS information
  51990. */
  51991. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51992. private static _FloatView;
  51993. private static _Int32View;
  51994. private static _ToHalfFloat;
  51995. private static _FromHalfFloat;
  51996. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51997. private static _GetHalfFloatRGBAArrayBuffer;
  51998. private static _GetFloatRGBAArrayBuffer;
  51999. private static _GetFloatAsUIntRGBAArrayBuffer;
  52000. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52001. private static _GetRGBAArrayBuffer;
  52002. private static _ExtractLongWordOrder;
  52003. private static _GetRGBArrayBuffer;
  52004. private static _GetLuminanceArrayBuffer;
  52005. /**
  52006. * Uploads DDS Levels to a Babylon Texture
  52007. * @hidden
  52008. */
  52009. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52010. }
  52011. interface ThinEngine {
  52012. /**
  52013. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52014. * @param rootUrl defines the url where the file to load is located
  52015. * @param scene defines the current scene
  52016. * @param lodScale defines scale to apply to the mip map selection
  52017. * @param lodOffset defines offset to apply to the mip map selection
  52018. * @param onLoad defines an optional callback raised when the texture is loaded
  52019. * @param onError defines an optional callback raised if there is an issue to load the texture
  52020. * @param format defines the format of the data
  52021. * @param forcedExtension defines the extension to use to pick the right loader
  52022. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52023. * @returns the cube texture as an InternalTexture
  52024. */
  52025. 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;
  52026. }
  52027. }
  52028. declare module BABYLON {
  52029. /**
  52030. * Implementation of the DDS Texture Loader.
  52031. * @hidden
  52032. */
  52033. export class _DDSTextureLoader implements IInternalTextureLoader {
  52034. /**
  52035. * Defines wether the loader supports cascade loading the different faces.
  52036. */
  52037. readonly supportCascades: boolean;
  52038. /**
  52039. * This returns if the loader support the current file information.
  52040. * @param extension defines the file extension of the file being loaded
  52041. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52042. * @param fallback defines the fallback internal texture if any
  52043. * @param isBase64 defines whether the texture is encoded as a base64
  52044. * @param isBuffer defines whether the texture data are stored as a buffer
  52045. * @returns true if the loader can load the specified file
  52046. */
  52047. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52048. /**
  52049. * Transform the url before loading if required.
  52050. * @param rootUrl the url of the texture
  52051. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52052. * @returns the transformed texture
  52053. */
  52054. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52055. /**
  52056. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52057. * @param rootUrl the url of the texture
  52058. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52059. * @returns the fallback texture
  52060. */
  52061. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52062. /**
  52063. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52064. * @param data contains the texture data
  52065. * @param texture defines the BabylonJS internal texture
  52066. * @param createPolynomials will be true if polynomials have been requested
  52067. * @param onLoad defines the callback to trigger once the texture is ready
  52068. * @param onError defines the callback to trigger in case of error
  52069. */
  52070. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52071. /**
  52072. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52073. * @param data contains the texture data
  52074. * @param texture defines the BabylonJS internal texture
  52075. * @param callback defines the method to call once ready to upload
  52076. */
  52077. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52078. }
  52079. }
  52080. declare module BABYLON {
  52081. /**
  52082. * Implementation of the ENV Texture Loader.
  52083. * @hidden
  52084. */
  52085. export class _ENVTextureLoader implements IInternalTextureLoader {
  52086. /**
  52087. * Defines wether the loader supports cascade loading the different faces.
  52088. */
  52089. readonly supportCascades: boolean;
  52090. /**
  52091. * This returns if the loader support the current file information.
  52092. * @param extension defines the file extension of the file being loaded
  52093. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52094. * @param fallback defines the fallback internal texture if any
  52095. * @param isBase64 defines whether the texture is encoded as a base64
  52096. * @param isBuffer defines whether the texture data are stored as a buffer
  52097. * @returns true if the loader can load the specified file
  52098. */
  52099. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52100. /**
  52101. * Transform the url before loading if required.
  52102. * @param rootUrl the url of the texture
  52103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52104. * @returns the transformed texture
  52105. */
  52106. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52107. /**
  52108. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52109. * @param rootUrl the url of the texture
  52110. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52111. * @returns the fallback texture
  52112. */
  52113. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52114. /**
  52115. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52116. * @param data contains the texture data
  52117. * @param texture defines the BabylonJS internal texture
  52118. * @param createPolynomials will be true if polynomials have been requested
  52119. * @param onLoad defines the callback to trigger once the texture is ready
  52120. * @param onError defines the callback to trigger in case of error
  52121. */
  52122. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52123. /**
  52124. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52125. * @param data contains the texture data
  52126. * @param texture defines the BabylonJS internal texture
  52127. * @param callback defines the method to call once ready to upload
  52128. */
  52129. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52130. }
  52131. }
  52132. declare module BABYLON {
  52133. /**
  52134. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52135. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52136. */
  52137. export class KhronosTextureContainer {
  52138. /** contents of the KTX container file */
  52139. data: ArrayBufferView;
  52140. private static HEADER_LEN;
  52141. private static COMPRESSED_2D;
  52142. private static COMPRESSED_3D;
  52143. private static TEX_2D;
  52144. private static TEX_3D;
  52145. /**
  52146. * Gets the openGL type
  52147. */
  52148. glType: number;
  52149. /**
  52150. * Gets the openGL type size
  52151. */
  52152. glTypeSize: number;
  52153. /**
  52154. * Gets the openGL format
  52155. */
  52156. glFormat: number;
  52157. /**
  52158. * Gets the openGL internal format
  52159. */
  52160. glInternalFormat: number;
  52161. /**
  52162. * Gets the base internal format
  52163. */
  52164. glBaseInternalFormat: number;
  52165. /**
  52166. * Gets image width in pixel
  52167. */
  52168. pixelWidth: number;
  52169. /**
  52170. * Gets image height in pixel
  52171. */
  52172. pixelHeight: number;
  52173. /**
  52174. * Gets image depth in pixels
  52175. */
  52176. pixelDepth: number;
  52177. /**
  52178. * Gets the number of array elements
  52179. */
  52180. numberOfArrayElements: number;
  52181. /**
  52182. * Gets the number of faces
  52183. */
  52184. numberOfFaces: number;
  52185. /**
  52186. * Gets the number of mipmap levels
  52187. */
  52188. numberOfMipmapLevels: number;
  52189. /**
  52190. * Gets the bytes of key value data
  52191. */
  52192. bytesOfKeyValueData: number;
  52193. /**
  52194. * Gets the load type
  52195. */
  52196. loadType: number;
  52197. /**
  52198. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52199. */
  52200. isInvalid: boolean;
  52201. /**
  52202. * Creates a new KhronosTextureContainer
  52203. * @param data contents of the KTX container file
  52204. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52205. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52206. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52207. */
  52208. constructor(
  52209. /** contents of the KTX container file */
  52210. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52211. /**
  52212. * Uploads KTX content to a Babylon Texture.
  52213. * It is assumed that the texture has already been created & is currently bound
  52214. * @hidden
  52215. */
  52216. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52217. private _upload2DCompressedLevels;
  52218. }
  52219. }
  52220. declare module BABYLON {
  52221. /**
  52222. * Implementation of the KTX Texture Loader.
  52223. * @hidden
  52224. */
  52225. export class _KTXTextureLoader implements IInternalTextureLoader {
  52226. /**
  52227. * Defines wether the loader supports cascade loading the different faces.
  52228. */
  52229. readonly supportCascades: boolean;
  52230. /**
  52231. * This returns if the loader support the current file information.
  52232. * @param extension defines the file extension of the file being loaded
  52233. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52234. * @param fallback defines the fallback internal texture if any
  52235. * @param isBase64 defines whether the texture is encoded as a base64
  52236. * @param isBuffer defines whether the texture data are stored as a buffer
  52237. * @returns true if the loader can load the specified file
  52238. */
  52239. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52240. /**
  52241. * Transform the url before loading if required.
  52242. * @param rootUrl the url of the texture
  52243. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52244. * @returns the transformed texture
  52245. */
  52246. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52247. /**
  52248. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52249. * @param rootUrl the url of the texture
  52250. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52251. * @returns the fallback texture
  52252. */
  52253. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52254. /**
  52255. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52256. * @param data contains the texture data
  52257. * @param texture defines the BabylonJS internal texture
  52258. * @param createPolynomials will be true if polynomials have been requested
  52259. * @param onLoad defines the callback to trigger once the texture is ready
  52260. * @param onError defines the callback to trigger in case of error
  52261. */
  52262. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52263. /**
  52264. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52265. * @param data contains the texture data
  52266. * @param texture defines the BabylonJS internal texture
  52267. * @param callback defines the method to call once ready to upload
  52268. */
  52269. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52270. }
  52271. }
  52272. declare module BABYLON {
  52273. /** @hidden */
  52274. export var _forceSceneHelpersToBundle: boolean;
  52275. interface Scene {
  52276. /**
  52277. * Creates a default light for the scene.
  52278. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52279. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52280. */
  52281. createDefaultLight(replace?: boolean): void;
  52282. /**
  52283. * Creates a default camera for the scene.
  52284. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52285. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52286. * @param replace has default false, when true replaces the active camera in the scene
  52287. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52288. */
  52289. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52290. /**
  52291. * Creates a default camera and a default light.
  52292. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52293. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52294. * @param replace has the default false, when true replaces the active camera/light in the scene
  52295. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52296. */
  52297. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52298. /**
  52299. * Creates a new sky box
  52300. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52301. * @param environmentTexture defines the texture to use as environment texture
  52302. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52303. * @param scale defines the overall scale of the skybox
  52304. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52305. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52306. * @returns a new mesh holding the sky box
  52307. */
  52308. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52309. /**
  52310. * Creates a new environment
  52311. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52312. * @param options defines the options you can use to configure the environment
  52313. * @returns the new EnvironmentHelper
  52314. */
  52315. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52316. /**
  52317. * Creates a new VREXperienceHelper
  52318. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52319. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52320. * @returns a new VREXperienceHelper
  52321. */
  52322. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52323. /**
  52324. * Creates a new WebXRDefaultExperience
  52325. * @see http://doc.babylonjs.com/how_to/webxr
  52326. * @param options experience options
  52327. * @returns a promise for a new WebXRDefaultExperience
  52328. */
  52329. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52330. }
  52331. }
  52332. declare module BABYLON {
  52333. /**
  52334. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52335. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52336. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52337. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52338. */
  52339. export class VideoDome extends TransformNode {
  52340. /**
  52341. * Define the video source as a Monoscopic panoramic 360 video.
  52342. */
  52343. static readonly MODE_MONOSCOPIC: number;
  52344. /**
  52345. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52346. */
  52347. static readonly MODE_TOPBOTTOM: number;
  52348. /**
  52349. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52350. */
  52351. static readonly MODE_SIDEBYSIDE: number;
  52352. private _halfDome;
  52353. private _useDirectMapping;
  52354. /**
  52355. * The video texture being displayed on the sphere
  52356. */
  52357. protected _videoTexture: VideoTexture;
  52358. /**
  52359. * Gets the video texture being displayed on the sphere
  52360. */
  52361. get videoTexture(): VideoTexture;
  52362. /**
  52363. * The skybox material
  52364. */
  52365. protected _material: BackgroundMaterial;
  52366. /**
  52367. * The surface used for the skybox
  52368. */
  52369. protected _mesh: Mesh;
  52370. /**
  52371. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52372. */
  52373. private _halfDomeMask;
  52374. /**
  52375. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52376. * Also see the options.resolution property.
  52377. */
  52378. get fovMultiplier(): number;
  52379. set fovMultiplier(value: number);
  52380. private _videoMode;
  52381. /**
  52382. * Gets or set the current video mode for the video. It can be:
  52383. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52384. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52385. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52386. */
  52387. get videoMode(): number;
  52388. set videoMode(value: number);
  52389. /**
  52390. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52391. *
  52392. */
  52393. get halfDome(): boolean;
  52394. /**
  52395. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52396. */
  52397. set halfDome(enabled: boolean);
  52398. /**
  52399. * Oberserver used in Stereoscopic VR Mode.
  52400. */
  52401. private _onBeforeCameraRenderObserver;
  52402. /**
  52403. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52404. * @param name Element's name, child elements will append suffixes for their own names.
  52405. * @param urlsOrVideo defines the url(s) or the video element to use
  52406. * @param options An object containing optional or exposed sub element properties
  52407. */
  52408. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52409. resolution?: number;
  52410. clickToPlay?: boolean;
  52411. autoPlay?: boolean;
  52412. loop?: boolean;
  52413. size?: number;
  52414. poster?: string;
  52415. faceForward?: boolean;
  52416. useDirectMapping?: boolean;
  52417. halfDomeMode?: boolean;
  52418. }, scene: Scene);
  52419. private _changeVideoMode;
  52420. /**
  52421. * Releases resources associated with this node.
  52422. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52423. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52424. */
  52425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52426. }
  52427. }
  52428. declare module BABYLON {
  52429. /**
  52430. * This class can be used to get instrumentation data from a Babylon engine
  52431. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52432. */
  52433. export class EngineInstrumentation implements IDisposable {
  52434. /**
  52435. * Define the instrumented engine.
  52436. */
  52437. engine: Engine;
  52438. private _captureGPUFrameTime;
  52439. private _gpuFrameTimeToken;
  52440. private _gpuFrameTime;
  52441. private _captureShaderCompilationTime;
  52442. private _shaderCompilationTime;
  52443. private _onBeginFrameObserver;
  52444. private _onEndFrameObserver;
  52445. private _onBeforeShaderCompilationObserver;
  52446. private _onAfterShaderCompilationObserver;
  52447. /**
  52448. * Gets the perf counter used for GPU frame time
  52449. */
  52450. get gpuFrameTimeCounter(): PerfCounter;
  52451. /**
  52452. * Gets the GPU frame time capture status
  52453. */
  52454. get captureGPUFrameTime(): boolean;
  52455. /**
  52456. * Enable or disable the GPU frame time capture
  52457. */
  52458. set captureGPUFrameTime(value: boolean);
  52459. /**
  52460. * Gets the perf counter used for shader compilation time
  52461. */
  52462. get shaderCompilationTimeCounter(): PerfCounter;
  52463. /**
  52464. * Gets the shader compilation time capture status
  52465. */
  52466. get captureShaderCompilationTime(): boolean;
  52467. /**
  52468. * Enable or disable the shader compilation time capture
  52469. */
  52470. set captureShaderCompilationTime(value: boolean);
  52471. /**
  52472. * Instantiates a new engine instrumentation.
  52473. * This class can be used to get instrumentation data from a Babylon engine
  52474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52475. * @param engine Defines the engine to instrument
  52476. */
  52477. constructor(
  52478. /**
  52479. * Define the instrumented engine.
  52480. */
  52481. engine: Engine);
  52482. /**
  52483. * Dispose and release associated resources.
  52484. */
  52485. dispose(): void;
  52486. }
  52487. }
  52488. declare module BABYLON {
  52489. /**
  52490. * This class can be used to get instrumentation data from a Babylon engine
  52491. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52492. */
  52493. export class SceneInstrumentation implements IDisposable {
  52494. /**
  52495. * Defines the scene to instrument
  52496. */
  52497. scene: Scene;
  52498. private _captureActiveMeshesEvaluationTime;
  52499. private _activeMeshesEvaluationTime;
  52500. private _captureRenderTargetsRenderTime;
  52501. private _renderTargetsRenderTime;
  52502. private _captureFrameTime;
  52503. private _frameTime;
  52504. private _captureRenderTime;
  52505. private _renderTime;
  52506. private _captureInterFrameTime;
  52507. private _interFrameTime;
  52508. private _captureParticlesRenderTime;
  52509. private _particlesRenderTime;
  52510. private _captureSpritesRenderTime;
  52511. private _spritesRenderTime;
  52512. private _capturePhysicsTime;
  52513. private _physicsTime;
  52514. private _captureAnimationsTime;
  52515. private _animationsTime;
  52516. private _captureCameraRenderTime;
  52517. private _cameraRenderTime;
  52518. private _onBeforeActiveMeshesEvaluationObserver;
  52519. private _onAfterActiveMeshesEvaluationObserver;
  52520. private _onBeforeRenderTargetsRenderObserver;
  52521. private _onAfterRenderTargetsRenderObserver;
  52522. private _onAfterRenderObserver;
  52523. private _onBeforeDrawPhaseObserver;
  52524. private _onAfterDrawPhaseObserver;
  52525. private _onBeforeAnimationsObserver;
  52526. private _onBeforeParticlesRenderingObserver;
  52527. private _onAfterParticlesRenderingObserver;
  52528. private _onBeforeSpritesRenderingObserver;
  52529. private _onAfterSpritesRenderingObserver;
  52530. private _onBeforePhysicsObserver;
  52531. private _onAfterPhysicsObserver;
  52532. private _onAfterAnimationsObserver;
  52533. private _onBeforeCameraRenderObserver;
  52534. private _onAfterCameraRenderObserver;
  52535. /**
  52536. * Gets the perf counter used for active meshes evaluation time
  52537. */
  52538. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52539. /**
  52540. * Gets the active meshes evaluation time capture status
  52541. */
  52542. get captureActiveMeshesEvaluationTime(): boolean;
  52543. /**
  52544. * Enable or disable the active meshes evaluation time capture
  52545. */
  52546. set captureActiveMeshesEvaluationTime(value: boolean);
  52547. /**
  52548. * Gets the perf counter used for render targets render time
  52549. */
  52550. get renderTargetsRenderTimeCounter(): PerfCounter;
  52551. /**
  52552. * Gets the render targets render time capture status
  52553. */
  52554. get captureRenderTargetsRenderTime(): boolean;
  52555. /**
  52556. * Enable or disable the render targets render time capture
  52557. */
  52558. set captureRenderTargetsRenderTime(value: boolean);
  52559. /**
  52560. * Gets the perf counter used for particles render time
  52561. */
  52562. get particlesRenderTimeCounter(): PerfCounter;
  52563. /**
  52564. * Gets the particles render time capture status
  52565. */
  52566. get captureParticlesRenderTime(): boolean;
  52567. /**
  52568. * Enable or disable the particles render time capture
  52569. */
  52570. set captureParticlesRenderTime(value: boolean);
  52571. /**
  52572. * Gets the perf counter used for sprites render time
  52573. */
  52574. get spritesRenderTimeCounter(): PerfCounter;
  52575. /**
  52576. * Gets the sprites render time capture status
  52577. */
  52578. get captureSpritesRenderTime(): boolean;
  52579. /**
  52580. * Enable or disable the sprites render time capture
  52581. */
  52582. set captureSpritesRenderTime(value: boolean);
  52583. /**
  52584. * Gets the perf counter used for physics time
  52585. */
  52586. get physicsTimeCounter(): PerfCounter;
  52587. /**
  52588. * Gets the physics time capture status
  52589. */
  52590. get capturePhysicsTime(): boolean;
  52591. /**
  52592. * Enable or disable the physics time capture
  52593. */
  52594. set capturePhysicsTime(value: boolean);
  52595. /**
  52596. * Gets the perf counter used for animations time
  52597. */
  52598. get animationsTimeCounter(): PerfCounter;
  52599. /**
  52600. * Gets the animations time capture status
  52601. */
  52602. get captureAnimationsTime(): boolean;
  52603. /**
  52604. * Enable or disable the animations time capture
  52605. */
  52606. set captureAnimationsTime(value: boolean);
  52607. /**
  52608. * Gets the perf counter used for frame time capture
  52609. */
  52610. get frameTimeCounter(): PerfCounter;
  52611. /**
  52612. * Gets the frame time capture status
  52613. */
  52614. get captureFrameTime(): boolean;
  52615. /**
  52616. * Enable or disable the frame time capture
  52617. */
  52618. set captureFrameTime(value: boolean);
  52619. /**
  52620. * Gets the perf counter used for inter-frames time capture
  52621. */
  52622. get interFrameTimeCounter(): PerfCounter;
  52623. /**
  52624. * Gets the inter-frames time capture status
  52625. */
  52626. get captureInterFrameTime(): boolean;
  52627. /**
  52628. * Enable or disable the inter-frames time capture
  52629. */
  52630. set captureInterFrameTime(value: boolean);
  52631. /**
  52632. * Gets the perf counter used for render time capture
  52633. */
  52634. get renderTimeCounter(): PerfCounter;
  52635. /**
  52636. * Gets the render time capture status
  52637. */
  52638. get captureRenderTime(): boolean;
  52639. /**
  52640. * Enable or disable the render time capture
  52641. */
  52642. set captureRenderTime(value: boolean);
  52643. /**
  52644. * Gets the perf counter used for camera render time capture
  52645. */
  52646. get cameraRenderTimeCounter(): PerfCounter;
  52647. /**
  52648. * Gets the camera render time capture status
  52649. */
  52650. get captureCameraRenderTime(): boolean;
  52651. /**
  52652. * Enable or disable the camera render time capture
  52653. */
  52654. set captureCameraRenderTime(value: boolean);
  52655. /**
  52656. * Gets the perf counter used for draw calls
  52657. */
  52658. get drawCallsCounter(): PerfCounter;
  52659. /**
  52660. * Instantiates a new scene instrumentation.
  52661. * This class can be used to get instrumentation data from a Babylon engine
  52662. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52663. * @param scene Defines the scene to instrument
  52664. */
  52665. constructor(
  52666. /**
  52667. * Defines the scene to instrument
  52668. */
  52669. scene: Scene);
  52670. /**
  52671. * Dispose and release associated resources.
  52672. */
  52673. dispose(): void;
  52674. }
  52675. }
  52676. declare module BABYLON {
  52677. /** @hidden */
  52678. export var glowMapGenerationPixelShader: {
  52679. name: string;
  52680. shader: string;
  52681. };
  52682. }
  52683. declare module BABYLON {
  52684. /** @hidden */
  52685. export var glowMapGenerationVertexShader: {
  52686. name: string;
  52687. shader: string;
  52688. };
  52689. }
  52690. declare module BABYLON {
  52691. /**
  52692. * Effect layer options. This helps customizing the behaviour
  52693. * of the effect layer.
  52694. */
  52695. export interface IEffectLayerOptions {
  52696. /**
  52697. * Multiplication factor apply to the canvas size to compute the render target size
  52698. * used to generated the objects (the smaller the faster).
  52699. */
  52700. mainTextureRatio: number;
  52701. /**
  52702. * Enforces a fixed size texture to ensure effect stability across devices.
  52703. */
  52704. mainTextureFixedSize?: number;
  52705. /**
  52706. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52707. */
  52708. alphaBlendingMode: number;
  52709. /**
  52710. * The camera attached to the layer.
  52711. */
  52712. camera: Nullable<Camera>;
  52713. /**
  52714. * The rendering group to draw the layer in.
  52715. */
  52716. renderingGroupId: number;
  52717. }
  52718. /**
  52719. * The effect layer Helps adding post process effect blended with the main pass.
  52720. *
  52721. * This can be for instance use to generate glow or higlight effects on the scene.
  52722. *
  52723. * The effect layer class can not be used directly and is intented to inherited from to be
  52724. * customized per effects.
  52725. */
  52726. export abstract class EffectLayer {
  52727. private _vertexBuffers;
  52728. private _indexBuffer;
  52729. private _cachedDefines;
  52730. private _effectLayerMapGenerationEffect;
  52731. private _effectLayerOptions;
  52732. private _mergeEffect;
  52733. protected _scene: Scene;
  52734. protected _engine: Engine;
  52735. protected _maxSize: number;
  52736. protected _mainTextureDesiredSize: ISize;
  52737. protected _mainTexture: RenderTargetTexture;
  52738. protected _shouldRender: boolean;
  52739. protected _postProcesses: PostProcess[];
  52740. protected _textures: BaseTexture[];
  52741. protected _emissiveTextureAndColor: {
  52742. texture: Nullable<BaseTexture>;
  52743. color: Color4;
  52744. };
  52745. /**
  52746. * The name of the layer
  52747. */
  52748. name: string;
  52749. /**
  52750. * The clear color of the texture used to generate the glow map.
  52751. */
  52752. neutralColor: Color4;
  52753. /**
  52754. * Specifies whether the highlight layer is enabled or not.
  52755. */
  52756. isEnabled: boolean;
  52757. /**
  52758. * Gets the camera attached to the layer.
  52759. */
  52760. get camera(): Nullable<Camera>;
  52761. /**
  52762. * Gets the rendering group id the layer should render in.
  52763. */
  52764. get renderingGroupId(): number;
  52765. set renderingGroupId(renderingGroupId: number);
  52766. /**
  52767. * An event triggered when the effect layer has been disposed.
  52768. */
  52769. onDisposeObservable: Observable<EffectLayer>;
  52770. /**
  52771. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52772. */
  52773. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52774. /**
  52775. * An event triggered when the generated texture is being merged in the scene.
  52776. */
  52777. onBeforeComposeObservable: Observable<EffectLayer>;
  52778. /**
  52779. * An event triggered when the mesh is rendered into the effect render target.
  52780. */
  52781. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52782. /**
  52783. * An event triggered after the mesh has been rendered into the effect render target.
  52784. */
  52785. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52786. /**
  52787. * An event triggered when the generated texture has been merged in the scene.
  52788. */
  52789. onAfterComposeObservable: Observable<EffectLayer>;
  52790. /**
  52791. * An event triggered when the efffect layer changes its size.
  52792. */
  52793. onSizeChangedObservable: Observable<EffectLayer>;
  52794. /** @hidden */
  52795. static _SceneComponentInitialization: (scene: Scene) => void;
  52796. /**
  52797. * Instantiates a new effect Layer and references it in the scene.
  52798. * @param name The name of the layer
  52799. * @param scene The scene to use the layer in
  52800. */
  52801. constructor(
  52802. /** The Friendly of the effect in the scene */
  52803. name: string, scene: Scene);
  52804. /**
  52805. * Get the effect name of the layer.
  52806. * @return The effect name
  52807. */
  52808. abstract getEffectName(): string;
  52809. /**
  52810. * Checks for the readiness of the element composing the layer.
  52811. * @param subMesh the mesh to check for
  52812. * @param useInstances specify whether or not to use instances to render the mesh
  52813. * @return true if ready otherwise, false
  52814. */
  52815. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52816. /**
  52817. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52818. * @returns true if the effect requires stencil during the main canvas render pass.
  52819. */
  52820. abstract needStencil(): boolean;
  52821. /**
  52822. * Create the merge effect. This is the shader use to blit the information back
  52823. * to the main canvas at the end of the scene rendering.
  52824. * @returns The effect containing the shader used to merge the effect on the main canvas
  52825. */
  52826. protected abstract _createMergeEffect(): Effect;
  52827. /**
  52828. * Creates the render target textures and post processes used in the effect layer.
  52829. */
  52830. protected abstract _createTextureAndPostProcesses(): void;
  52831. /**
  52832. * Implementation specific of rendering the generating effect on the main canvas.
  52833. * @param effect The effect used to render through
  52834. */
  52835. protected abstract _internalRender(effect: Effect): void;
  52836. /**
  52837. * Sets the required values for both the emissive texture and and the main color.
  52838. */
  52839. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52840. /**
  52841. * Free any resources and references associated to a mesh.
  52842. * Internal use
  52843. * @param mesh The mesh to free.
  52844. */
  52845. abstract _disposeMesh(mesh: Mesh): void;
  52846. /**
  52847. * Serializes this layer (Glow or Highlight for example)
  52848. * @returns a serialized layer object
  52849. */
  52850. abstract serialize?(): any;
  52851. /**
  52852. * Initializes the effect layer with the required options.
  52853. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52854. */
  52855. protected _init(options: Partial<IEffectLayerOptions>): void;
  52856. /**
  52857. * Generates the index buffer of the full screen quad blending to the main canvas.
  52858. */
  52859. private _generateIndexBuffer;
  52860. /**
  52861. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52862. */
  52863. private _generateVertexBuffer;
  52864. /**
  52865. * Sets the main texture desired size which is the closest power of two
  52866. * of the engine canvas size.
  52867. */
  52868. private _setMainTextureSize;
  52869. /**
  52870. * Creates the main texture for the effect layer.
  52871. */
  52872. protected _createMainTexture(): void;
  52873. /**
  52874. * Adds specific effects defines.
  52875. * @param defines The defines to add specifics to.
  52876. */
  52877. protected _addCustomEffectDefines(defines: string[]): void;
  52878. /**
  52879. * Checks for the readiness of the element composing the layer.
  52880. * @param subMesh the mesh to check for
  52881. * @param useInstances specify whether or not to use instances to render the mesh
  52882. * @param emissiveTexture the associated emissive texture used to generate the glow
  52883. * @return true if ready otherwise, false
  52884. */
  52885. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52886. /**
  52887. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52888. */
  52889. render(): void;
  52890. /**
  52891. * Determine if a given mesh will be used in the current effect.
  52892. * @param mesh mesh to test
  52893. * @returns true if the mesh will be used
  52894. */
  52895. hasMesh(mesh: AbstractMesh): boolean;
  52896. /**
  52897. * Returns true if the layer contains information to display, otherwise false.
  52898. * @returns true if the glow layer should be rendered
  52899. */
  52900. shouldRender(): boolean;
  52901. /**
  52902. * Returns true if the mesh should render, otherwise false.
  52903. * @param mesh The mesh to render
  52904. * @returns true if it should render otherwise false
  52905. */
  52906. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52907. /**
  52908. * Returns true if the mesh can be rendered, otherwise false.
  52909. * @param mesh The mesh to render
  52910. * @param material The material used on the mesh
  52911. * @returns true if it can be rendered otherwise false
  52912. */
  52913. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52914. /**
  52915. * Returns true if the mesh should render, otherwise false.
  52916. * @param mesh The mesh to render
  52917. * @returns true if it should render otherwise false
  52918. */
  52919. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52920. /**
  52921. * Renders the submesh passed in parameter to the generation map.
  52922. */
  52923. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52924. /**
  52925. * Defines whether the current material of the mesh should be use to render the effect.
  52926. * @param mesh defines the current mesh to render
  52927. */
  52928. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52929. /**
  52930. * Rebuild the required buffers.
  52931. * @hidden Internal use only.
  52932. */
  52933. _rebuild(): void;
  52934. /**
  52935. * Dispose only the render target textures and post process.
  52936. */
  52937. private _disposeTextureAndPostProcesses;
  52938. /**
  52939. * Dispose the highlight layer and free resources.
  52940. */
  52941. dispose(): void;
  52942. /**
  52943. * Gets the class name of the effect layer
  52944. * @returns the string with the class name of the effect layer
  52945. */
  52946. getClassName(): string;
  52947. /**
  52948. * Creates an effect layer from parsed effect layer data
  52949. * @param parsedEffectLayer defines effect layer data
  52950. * @param scene defines the current scene
  52951. * @param rootUrl defines the root URL containing the effect layer information
  52952. * @returns a parsed effect Layer
  52953. */
  52954. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52955. }
  52956. }
  52957. declare module BABYLON {
  52958. interface AbstractScene {
  52959. /**
  52960. * The list of effect layers (highlights/glow) added to the scene
  52961. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52962. * @see http://doc.babylonjs.com/how_to/glow_layer
  52963. */
  52964. effectLayers: Array<EffectLayer>;
  52965. /**
  52966. * Removes the given effect layer from this scene.
  52967. * @param toRemove defines the effect layer to remove
  52968. * @returns the index of the removed effect layer
  52969. */
  52970. removeEffectLayer(toRemove: EffectLayer): number;
  52971. /**
  52972. * Adds the given effect layer to this scene
  52973. * @param newEffectLayer defines the effect layer to add
  52974. */
  52975. addEffectLayer(newEffectLayer: EffectLayer): void;
  52976. }
  52977. /**
  52978. * Defines the layer scene component responsible to manage any effect layers
  52979. * in a given scene.
  52980. */
  52981. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52982. /**
  52983. * The component name helpfull to identify the component in the list of scene components.
  52984. */
  52985. readonly name: string;
  52986. /**
  52987. * The scene the component belongs to.
  52988. */
  52989. scene: Scene;
  52990. private _engine;
  52991. private _renderEffects;
  52992. private _needStencil;
  52993. private _previousStencilState;
  52994. /**
  52995. * Creates a new instance of the component for the given scene
  52996. * @param scene Defines the scene to register the component in
  52997. */
  52998. constructor(scene: Scene);
  52999. /**
  53000. * Registers the component in a given scene
  53001. */
  53002. register(): void;
  53003. /**
  53004. * Rebuilds the elements related to this component in case of
  53005. * context lost for instance.
  53006. */
  53007. rebuild(): void;
  53008. /**
  53009. * Serializes the component data to the specified json object
  53010. * @param serializationObject The object to serialize to
  53011. */
  53012. serialize(serializationObject: any): void;
  53013. /**
  53014. * Adds all the elements from the container to the scene
  53015. * @param container the container holding the elements
  53016. */
  53017. addFromContainer(container: AbstractScene): void;
  53018. /**
  53019. * Removes all the elements in the container from the scene
  53020. * @param container contains the elements to remove
  53021. * @param dispose if the removed element should be disposed (default: false)
  53022. */
  53023. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53024. /**
  53025. * Disposes the component and the associated ressources.
  53026. */
  53027. dispose(): void;
  53028. private _isReadyForMesh;
  53029. private _renderMainTexture;
  53030. private _setStencil;
  53031. private _setStencilBack;
  53032. private _draw;
  53033. private _drawCamera;
  53034. private _drawRenderingGroup;
  53035. }
  53036. }
  53037. declare module BABYLON {
  53038. /** @hidden */
  53039. export var glowMapMergePixelShader: {
  53040. name: string;
  53041. shader: string;
  53042. };
  53043. }
  53044. declare module BABYLON {
  53045. /** @hidden */
  53046. export var glowMapMergeVertexShader: {
  53047. name: string;
  53048. shader: string;
  53049. };
  53050. }
  53051. declare module BABYLON {
  53052. interface AbstractScene {
  53053. /**
  53054. * Return a the first highlight layer of the scene with a given name.
  53055. * @param name The name of the highlight layer to look for.
  53056. * @return The highlight layer if found otherwise null.
  53057. */
  53058. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53059. }
  53060. /**
  53061. * Glow layer options. This helps customizing the behaviour
  53062. * of the glow layer.
  53063. */
  53064. export interface IGlowLayerOptions {
  53065. /**
  53066. * Multiplication factor apply to the canvas size to compute the render target size
  53067. * used to generated the glowing objects (the smaller the faster).
  53068. */
  53069. mainTextureRatio: number;
  53070. /**
  53071. * Enforces a fixed size texture to ensure resize independant blur.
  53072. */
  53073. mainTextureFixedSize?: number;
  53074. /**
  53075. * How big is the kernel of the blur texture.
  53076. */
  53077. blurKernelSize: number;
  53078. /**
  53079. * The camera attached to the layer.
  53080. */
  53081. camera: Nullable<Camera>;
  53082. /**
  53083. * Enable MSAA by chosing the number of samples.
  53084. */
  53085. mainTextureSamples?: number;
  53086. /**
  53087. * The rendering group to draw the layer in.
  53088. */
  53089. renderingGroupId: number;
  53090. }
  53091. /**
  53092. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53093. *
  53094. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53095. *
  53096. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53097. */
  53098. export class GlowLayer extends EffectLayer {
  53099. /**
  53100. * Effect Name of the layer.
  53101. */
  53102. static readonly EffectName: string;
  53103. /**
  53104. * The default blur kernel size used for the glow.
  53105. */
  53106. static DefaultBlurKernelSize: number;
  53107. /**
  53108. * The default texture size ratio used for the glow.
  53109. */
  53110. static DefaultTextureRatio: number;
  53111. /**
  53112. * Sets the kernel size of the blur.
  53113. */
  53114. set blurKernelSize(value: number);
  53115. /**
  53116. * Gets the kernel size of the blur.
  53117. */
  53118. get blurKernelSize(): number;
  53119. /**
  53120. * Sets the glow intensity.
  53121. */
  53122. set intensity(value: number);
  53123. /**
  53124. * Gets the glow intensity.
  53125. */
  53126. get intensity(): number;
  53127. private _options;
  53128. private _intensity;
  53129. private _horizontalBlurPostprocess1;
  53130. private _verticalBlurPostprocess1;
  53131. private _horizontalBlurPostprocess2;
  53132. private _verticalBlurPostprocess2;
  53133. private _blurTexture1;
  53134. private _blurTexture2;
  53135. private _postProcesses1;
  53136. private _postProcesses2;
  53137. private _includedOnlyMeshes;
  53138. private _excludedMeshes;
  53139. private _meshesUsingTheirOwnMaterials;
  53140. /**
  53141. * Callback used to let the user override the color selection on a per mesh basis
  53142. */
  53143. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53144. /**
  53145. * Callback used to let the user override the texture selection on a per mesh basis
  53146. */
  53147. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53148. /**
  53149. * Instantiates a new glow Layer and references it to the scene.
  53150. * @param name The name of the layer
  53151. * @param scene The scene to use the layer in
  53152. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53153. */
  53154. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53155. /**
  53156. * Get the effect name of the layer.
  53157. * @return The effect name
  53158. */
  53159. getEffectName(): string;
  53160. /**
  53161. * Create the merge effect. This is the shader use to blit the information back
  53162. * to the main canvas at the end of the scene rendering.
  53163. */
  53164. protected _createMergeEffect(): Effect;
  53165. /**
  53166. * Creates the render target textures and post processes used in the glow layer.
  53167. */
  53168. protected _createTextureAndPostProcesses(): void;
  53169. /**
  53170. * Checks for the readiness of the element composing the layer.
  53171. * @param subMesh the mesh to check for
  53172. * @param useInstances specify wether or not to use instances to render the mesh
  53173. * @param emissiveTexture the associated emissive texture used to generate the glow
  53174. * @return true if ready otherwise, false
  53175. */
  53176. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53177. /**
  53178. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53179. */
  53180. needStencil(): boolean;
  53181. /**
  53182. * Returns true if the mesh can be rendered, otherwise false.
  53183. * @param mesh The mesh to render
  53184. * @param material The material used on the mesh
  53185. * @returns true if it can be rendered otherwise false
  53186. */
  53187. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53188. /**
  53189. * Implementation specific of rendering the generating effect on the main canvas.
  53190. * @param effect The effect used to render through
  53191. */
  53192. protected _internalRender(effect: Effect): void;
  53193. /**
  53194. * Sets the required values for both the emissive texture and and the main color.
  53195. */
  53196. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53197. /**
  53198. * Returns true if the mesh should render, otherwise false.
  53199. * @param mesh The mesh to render
  53200. * @returns true if it should render otherwise false
  53201. */
  53202. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53203. /**
  53204. * Adds specific effects defines.
  53205. * @param defines The defines to add specifics to.
  53206. */
  53207. protected _addCustomEffectDefines(defines: string[]): void;
  53208. /**
  53209. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53210. * @param mesh The mesh to exclude from the glow layer
  53211. */
  53212. addExcludedMesh(mesh: Mesh): void;
  53213. /**
  53214. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53215. * @param mesh The mesh to remove
  53216. */
  53217. removeExcludedMesh(mesh: Mesh): void;
  53218. /**
  53219. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53220. * @param mesh The mesh to include in the glow layer
  53221. */
  53222. addIncludedOnlyMesh(mesh: Mesh): void;
  53223. /**
  53224. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53225. * @param mesh The mesh to remove
  53226. */
  53227. removeIncludedOnlyMesh(mesh: Mesh): void;
  53228. /**
  53229. * Determine if a given mesh will be used in the glow layer
  53230. * @param mesh The mesh to test
  53231. * @returns true if the mesh will be highlighted by the current glow layer
  53232. */
  53233. hasMesh(mesh: AbstractMesh): boolean;
  53234. /**
  53235. * Defines whether the current material of the mesh should be use to render the effect.
  53236. * @param mesh defines the current mesh to render
  53237. */
  53238. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53239. /**
  53240. * Add a mesh to be rendered through its own material and not with emissive only.
  53241. * @param mesh The mesh for which we need to use its material
  53242. */
  53243. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53244. /**
  53245. * Remove a mesh from being rendered through its own material and not with emissive only.
  53246. * @param mesh The mesh for which we need to not use its material
  53247. */
  53248. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53249. /**
  53250. * Free any resources and references associated to a mesh.
  53251. * Internal use
  53252. * @param mesh The mesh to free.
  53253. * @hidden
  53254. */
  53255. _disposeMesh(mesh: Mesh): void;
  53256. /**
  53257. * Gets the class name of the effect layer
  53258. * @returns the string with the class name of the effect layer
  53259. */
  53260. getClassName(): string;
  53261. /**
  53262. * Serializes this glow layer
  53263. * @returns a serialized glow layer object
  53264. */
  53265. serialize(): any;
  53266. /**
  53267. * Creates a Glow Layer from parsed glow layer data
  53268. * @param parsedGlowLayer defines glow layer data
  53269. * @param scene defines the current scene
  53270. * @param rootUrl defines the root URL containing the glow layer information
  53271. * @returns a parsed Glow Layer
  53272. */
  53273. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53274. }
  53275. }
  53276. declare module BABYLON {
  53277. /** @hidden */
  53278. export var glowBlurPostProcessPixelShader: {
  53279. name: string;
  53280. shader: string;
  53281. };
  53282. }
  53283. declare module BABYLON {
  53284. interface AbstractScene {
  53285. /**
  53286. * Return a the first highlight layer of the scene with a given name.
  53287. * @param name The name of the highlight layer to look for.
  53288. * @return The highlight layer if found otherwise null.
  53289. */
  53290. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53291. }
  53292. /**
  53293. * Highlight layer options. This helps customizing the behaviour
  53294. * of the highlight layer.
  53295. */
  53296. export interface IHighlightLayerOptions {
  53297. /**
  53298. * Multiplication factor apply to the canvas size to compute the render target size
  53299. * used to generated the glowing objects (the smaller the faster).
  53300. */
  53301. mainTextureRatio: number;
  53302. /**
  53303. * Enforces a fixed size texture to ensure resize independant blur.
  53304. */
  53305. mainTextureFixedSize?: number;
  53306. /**
  53307. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53308. * of the picture to blur (the smaller the faster).
  53309. */
  53310. blurTextureSizeRatio: number;
  53311. /**
  53312. * How big in texel of the blur texture is the vertical blur.
  53313. */
  53314. blurVerticalSize: number;
  53315. /**
  53316. * How big in texel of the blur texture is the horizontal blur.
  53317. */
  53318. blurHorizontalSize: number;
  53319. /**
  53320. * Alpha blending mode used to apply the blur. Default is combine.
  53321. */
  53322. alphaBlendingMode: number;
  53323. /**
  53324. * The camera attached to the layer.
  53325. */
  53326. camera: Nullable<Camera>;
  53327. /**
  53328. * Should we display highlight as a solid stroke?
  53329. */
  53330. isStroke?: boolean;
  53331. /**
  53332. * The rendering group to draw the layer in.
  53333. */
  53334. renderingGroupId: number;
  53335. }
  53336. /**
  53337. * The highlight layer Helps adding a glow effect around a mesh.
  53338. *
  53339. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53340. * glowy meshes to your scene.
  53341. *
  53342. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53343. */
  53344. export class HighlightLayer extends EffectLayer {
  53345. name: string;
  53346. /**
  53347. * Effect Name of the highlight layer.
  53348. */
  53349. static readonly EffectName: string;
  53350. /**
  53351. * The neutral color used during the preparation of the glow effect.
  53352. * This is black by default as the blend operation is a blend operation.
  53353. */
  53354. static NeutralColor: Color4;
  53355. /**
  53356. * Stencil value used for glowing meshes.
  53357. */
  53358. static GlowingMeshStencilReference: number;
  53359. /**
  53360. * Stencil value used for the other meshes in the scene.
  53361. */
  53362. static NormalMeshStencilReference: number;
  53363. /**
  53364. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53365. */
  53366. innerGlow: boolean;
  53367. /**
  53368. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53369. */
  53370. outerGlow: boolean;
  53371. /**
  53372. * Specifies the horizontal size of the blur.
  53373. */
  53374. set blurHorizontalSize(value: number);
  53375. /**
  53376. * Specifies the vertical size of the blur.
  53377. */
  53378. set blurVerticalSize(value: number);
  53379. /**
  53380. * Gets the horizontal size of the blur.
  53381. */
  53382. get blurHorizontalSize(): number;
  53383. /**
  53384. * Gets the vertical size of the blur.
  53385. */
  53386. get blurVerticalSize(): number;
  53387. /**
  53388. * An event triggered when the highlight layer is being blurred.
  53389. */
  53390. onBeforeBlurObservable: Observable<HighlightLayer>;
  53391. /**
  53392. * An event triggered when the highlight layer has been blurred.
  53393. */
  53394. onAfterBlurObservable: Observable<HighlightLayer>;
  53395. private _instanceGlowingMeshStencilReference;
  53396. private _options;
  53397. private _downSamplePostprocess;
  53398. private _horizontalBlurPostprocess;
  53399. private _verticalBlurPostprocess;
  53400. private _blurTexture;
  53401. private _meshes;
  53402. private _excludedMeshes;
  53403. /**
  53404. * Instantiates a new highlight Layer and references it to the scene..
  53405. * @param name The name of the layer
  53406. * @param scene The scene to use the layer in
  53407. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53408. */
  53409. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53410. /**
  53411. * Get the effect name of the layer.
  53412. * @return The effect name
  53413. */
  53414. getEffectName(): string;
  53415. /**
  53416. * Create the merge effect. This is the shader use to blit the information back
  53417. * to the main canvas at the end of the scene rendering.
  53418. */
  53419. protected _createMergeEffect(): Effect;
  53420. /**
  53421. * Creates the render target textures and post processes used in the highlight layer.
  53422. */
  53423. protected _createTextureAndPostProcesses(): void;
  53424. /**
  53425. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53426. */
  53427. needStencil(): boolean;
  53428. /**
  53429. * Checks for the readiness of the element composing the layer.
  53430. * @param subMesh the mesh to check for
  53431. * @param useInstances specify wether or not to use instances to render the mesh
  53432. * @param emissiveTexture the associated emissive texture used to generate the glow
  53433. * @return true if ready otherwise, false
  53434. */
  53435. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53436. /**
  53437. * Implementation specific of rendering the generating effect on the main canvas.
  53438. * @param effect The effect used to render through
  53439. */
  53440. protected _internalRender(effect: Effect): void;
  53441. /**
  53442. * Returns true if the layer contains information to display, otherwise false.
  53443. */
  53444. shouldRender(): boolean;
  53445. /**
  53446. * Returns true if the mesh should render, otherwise false.
  53447. * @param mesh The mesh to render
  53448. * @returns true if it should render otherwise false
  53449. */
  53450. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53451. /**
  53452. * Sets the required values for both the emissive texture and and the main color.
  53453. */
  53454. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53455. /**
  53456. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53457. * @param mesh The mesh to exclude from the highlight layer
  53458. */
  53459. addExcludedMesh(mesh: Mesh): void;
  53460. /**
  53461. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53462. * @param mesh The mesh to highlight
  53463. */
  53464. removeExcludedMesh(mesh: Mesh): void;
  53465. /**
  53466. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53467. * @param mesh mesh to test
  53468. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53469. */
  53470. hasMesh(mesh: AbstractMesh): boolean;
  53471. /**
  53472. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53473. * @param mesh The mesh to highlight
  53474. * @param color The color of the highlight
  53475. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53476. */
  53477. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53478. /**
  53479. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53480. * @param mesh The mesh to highlight
  53481. */
  53482. removeMesh(mesh: Mesh): void;
  53483. /**
  53484. * Force the stencil to the normal expected value for none glowing parts
  53485. */
  53486. private _defaultStencilReference;
  53487. /**
  53488. * Free any resources and references associated to a mesh.
  53489. * Internal use
  53490. * @param mesh The mesh to free.
  53491. * @hidden
  53492. */
  53493. _disposeMesh(mesh: Mesh): void;
  53494. /**
  53495. * Dispose the highlight layer and free resources.
  53496. */
  53497. dispose(): void;
  53498. /**
  53499. * Gets the class name of the effect layer
  53500. * @returns the string with the class name of the effect layer
  53501. */
  53502. getClassName(): string;
  53503. /**
  53504. * Serializes this Highlight layer
  53505. * @returns a serialized Highlight layer object
  53506. */
  53507. serialize(): any;
  53508. /**
  53509. * Creates a Highlight layer from parsed Highlight layer data
  53510. * @param parsedHightlightLayer defines the Highlight layer data
  53511. * @param scene defines the current scene
  53512. * @param rootUrl defines the root URL containing the Highlight layer information
  53513. * @returns a parsed Highlight layer
  53514. */
  53515. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53516. }
  53517. }
  53518. declare module BABYLON {
  53519. interface AbstractScene {
  53520. /**
  53521. * The list of layers (background and foreground) of the scene
  53522. */
  53523. layers: Array<Layer>;
  53524. }
  53525. /**
  53526. * Defines the layer scene component responsible to manage any layers
  53527. * in a given scene.
  53528. */
  53529. export class LayerSceneComponent implements ISceneComponent {
  53530. /**
  53531. * The component name helpfull to identify the component in the list of scene components.
  53532. */
  53533. readonly name: string;
  53534. /**
  53535. * The scene the component belongs to.
  53536. */
  53537. scene: Scene;
  53538. private _engine;
  53539. /**
  53540. * Creates a new instance of the component for the given scene
  53541. * @param scene Defines the scene to register the component in
  53542. */
  53543. constructor(scene: Scene);
  53544. /**
  53545. * Registers the component in a given scene
  53546. */
  53547. register(): void;
  53548. /**
  53549. * Rebuilds the elements related to this component in case of
  53550. * context lost for instance.
  53551. */
  53552. rebuild(): void;
  53553. /**
  53554. * Disposes the component and the associated ressources.
  53555. */
  53556. dispose(): void;
  53557. private _draw;
  53558. private _drawCameraPredicate;
  53559. private _drawCameraBackground;
  53560. private _drawCameraForeground;
  53561. private _drawRenderTargetPredicate;
  53562. private _drawRenderTargetBackground;
  53563. private _drawRenderTargetForeground;
  53564. /**
  53565. * Adds all the elements from the container to the scene
  53566. * @param container the container holding the elements
  53567. */
  53568. addFromContainer(container: AbstractScene): void;
  53569. /**
  53570. * Removes all the elements in the container from the scene
  53571. * @param container contains the elements to remove
  53572. * @param dispose if the removed element should be disposed (default: false)
  53573. */
  53574. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53575. }
  53576. }
  53577. declare module BABYLON {
  53578. /** @hidden */
  53579. export var layerPixelShader: {
  53580. name: string;
  53581. shader: string;
  53582. };
  53583. }
  53584. declare module BABYLON {
  53585. /** @hidden */
  53586. export var layerVertexShader: {
  53587. name: string;
  53588. shader: string;
  53589. };
  53590. }
  53591. declare module BABYLON {
  53592. /**
  53593. * This represents a full screen 2d layer.
  53594. * This can be useful to display a picture in the background of your scene for instance.
  53595. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53596. */
  53597. export class Layer {
  53598. /**
  53599. * Define the name of the layer.
  53600. */
  53601. name: string;
  53602. /**
  53603. * Define the texture the layer should display.
  53604. */
  53605. texture: Nullable<Texture>;
  53606. /**
  53607. * Is the layer in background or foreground.
  53608. */
  53609. isBackground: boolean;
  53610. /**
  53611. * Define the color of the layer (instead of texture).
  53612. */
  53613. color: Color4;
  53614. /**
  53615. * Define the scale of the layer in order to zoom in out of the texture.
  53616. */
  53617. scale: Vector2;
  53618. /**
  53619. * Define an offset for the layer in order to shift the texture.
  53620. */
  53621. offset: Vector2;
  53622. /**
  53623. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53624. */
  53625. alphaBlendingMode: number;
  53626. /**
  53627. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53628. * Alpha test will not mix with the background color in case of transparency.
  53629. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53630. */
  53631. alphaTest: boolean;
  53632. /**
  53633. * Define a mask to restrict the layer to only some of the scene cameras.
  53634. */
  53635. layerMask: number;
  53636. /**
  53637. * Define the list of render target the layer is visible into.
  53638. */
  53639. renderTargetTextures: RenderTargetTexture[];
  53640. /**
  53641. * Define if the layer is only used in renderTarget or if it also
  53642. * renders in the main frame buffer of the canvas.
  53643. */
  53644. renderOnlyInRenderTargetTextures: boolean;
  53645. private _scene;
  53646. private _vertexBuffers;
  53647. private _indexBuffer;
  53648. private _effect;
  53649. private _previousDefines;
  53650. /**
  53651. * An event triggered when the layer is disposed.
  53652. */
  53653. onDisposeObservable: Observable<Layer>;
  53654. private _onDisposeObserver;
  53655. /**
  53656. * Back compatibility with callback before the onDisposeObservable existed.
  53657. * The set callback will be triggered when the layer has been disposed.
  53658. */
  53659. set onDispose(callback: () => void);
  53660. /**
  53661. * An event triggered before rendering the scene
  53662. */
  53663. onBeforeRenderObservable: Observable<Layer>;
  53664. private _onBeforeRenderObserver;
  53665. /**
  53666. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53667. * The set callback will be triggered just before rendering the layer.
  53668. */
  53669. set onBeforeRender(callback: () => void);
  53670. /**
  53671. * An event triggered after rendering the scene
  53672. */
  53673. onAfterRenderObservable: Observable<Layer>;
  53674. private _onAfterRenderObserver;
  53675. /**
  53676. * Back compatibility with callback before the onAfterRenderObservable existed.
  53677. * The set callback will be triggered just after rendering the layer.
  53678. */
  53679. set onAfterRender(callback: () => void);
  53680. /**
  53681. * Instantiates a new layer.
  53682. * This represents a full screen 2d layer.
  53683. * This can be useful to display a picture in the background of your scene for instance.
  53684. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53685. * @param name Define the name of the layer in the scene
  53686. * @param imgUrl Define the url of the texture to display in the layer
  53687. * @param scene Define the scene the layer belongs to
  53688. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53689. * @param color Defines a color for the layer
  53690. */
  53691. constructor(
  53692. /**
  53693. * Define the name of the layer.
  53694. */
  53695. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53696. private _createIndexBuffer;
  53697. /** @hidden */
  53698. _rebuild(): void;
  53699. /**
  53700. * Renders the layer in the scene.
  53701. */
  53702. render(): void;
  53703. /**
  53704. * Disposes and releases the associated ressources.
  53705. */
  53706. dispose(): void;
  53707. }
  53708. }
  53709. declare module BABYLON {
  53710. /** @hidden */
  53711. export var lensFlarePixelShader: {
  53712. name: string;
  53713. shader: string;
  53714. };
  53715. }
  53716. declare module BABYLON {
  53717. /** @hidden */
  53718. export var lensFlareVertexShader: {
  53719. name: string;
  53720. shader: string;
  53721. };
  53722. }
  53723. declare module BABYLON {
  53724. /**
  53725. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53726. * It is usually composed of several `lensFlare`.
  53727. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53728. */
  53729. export class LensFlareSystem {
  53730. /**
  53731. * Define the name of the lens flare system
  53732. */
  53733. name: string;
  53734. /**
  53735. * List of lens flares used in this system.
  53736. */
  53737. lensFlares: LensFlare[];
  53738. /**
  53739. * Define a limit from the border the lens flare can be visible.
  53740. */
  53741. borderLimit: number;
  53742. /**
  53743. * Define a viewport border we do not want to see the lens flare in.
  53744. */
  53745. viewportBorder: number;
  53746. /**
  53747. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53748. */
  53749. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53750. /**
  53751. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53752. */
  53753. layerMask: number;
  53754. /**
  53755. * Define the id of the lens flare system in the scene.
  53756. * (equal to name by default)
  53757. */
  53758. id: string;
  53759. private _scene;
  53760. private _emitter;
  53761. private _vertexBuffers;
  53762. private _indexBuffer;
  53763. private _effect;
  53764. private _positionX;
  53765. private _positionY;
  53766. private _isEnabled;
  53767. /** @hidden */
  53768. static _SceneComponentInitialization: (scene: Scene) => void;
  53769. /**
  53770. * Instantiates a lens flare system.
  53771. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53772. * It is usually composed of several `lensFlare`.
  53773. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53774. * @param name Define the name of the lens flare system in the scene
  53775. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53776. * @param scene Define the scene the lens flare system belongs to
  53777. */
  53778. constructor(
  53779. /**
  53780. * Define the name of the lens flare system
  53781. */
  53782. name: string, emitter: any, scene: Scene);
  53783. /**
  53784. * Define if the lens flare system is enabled.
  53785. */
  53786. get isEnabled(): boolean;
  53787. set isEnabled(value: boolean);
  53788. /**
  53789. * Get the scene the effects belongs to.
  53790. * @returns the scene holding the lens flare system
  53791. */
  53792. getScene(): Scene;
  53793. /**
  53794. * Get the emitter of the lens flare system.
  53795. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53796. * @returns the emitter of the lens flare system
  53797. */
  53798. getEmitter(): any;
  53799. /**
  53800. * Set the emitter of the lens flare system.
  53801. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53802. * @param newEmitter Define the new emitter of the system
  53803. */
  53804. setEmitter(newEmitter: any): void;
  53805. /**
  53806. * Get the lens flare system emitter position.
  53807. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53808. * @returns the position
  53809. */
  53810. getEmitterPosition(): Vector3;
  53811. /**
  53812. * @hidden
  53813. */
  53814. computeEffectivePosition(globalViewport: Viewport): boolean;
  53815. /** @hidden */
  53816. _isVisible(): boolean;
  53817. /**
  53818. * @hidden
  53819. */
  53820. render(): boolean;
  53821. /**
  53822. * Dispose and release the lens flare with its associated resources.
  53823. */
  53824. dispose(): void;
  53825. /**
  53826. * Parse a lens flare system from a JSON repressentation
  53827. * @param parsedLensFlareSystem Define the JSON to parse
  53828. * @param scene Define the scene the parsed system should be instantiated in
  53829. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53830. * @returns the parsed system
  53831. */
  53832. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53833. /**
  53834. * Serialize the current Lens Flare System into a JSON representation.
  53835. * @returns the serialized JSON
  53836. */
  53837. serialize(): any;
  53838. }
  53839. }
  53840. declare module BABYLON {
  53841. /**
  53842. * This represents one of the lens effect in a `lensFlareSystem`.
  53843. * It controls one of the indiviual texture used in the effect.
  53844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53845. */
  53846. export class LensFlare {
  53847. /**
  53848. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53849. */
  53850. size: number;
  53851. /**
  53852. * 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.
  53853. */
  53854. position: number;
  53855. /**
  53856. * Define the lens color.
  53857. */
  53858. color: Color3;
  53859. /**
  53860. * Define the lens texture.
  53861. */
  53862. texture: Nullable<Texture>;
  53863. /**
  53864. * Define the alpha mode to render this particular lens.
  53865. */
  53866. alphaMode: number;
  53867. private _system;
  53868. /**
  53869. * Creates a new Lens Flare.
  53870. * This represents one of the lens effect in a `lensFlareSystem`.
  53871. * It controls one of the indiviual texture used in the effect.
  53872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53873. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53874. * @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.
  53875. * @param color Define the lens color
  53876. * @param imgUrl Define the lens texture url
  53877. * @param system Define the `lensFlareSystem` this flare is part of
  53878. * @returns The newly created Lens Flare
  53879. */
  53880. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53881. /**
  53882. * Instantiates a new Lens Flare.
  53883. * This represents one of the lens effect in a `lensFlareSystem`.
  53884. * It controls one of the indiviual texture used in the effect.
  53885. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53886. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53887. * @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.
  53888. * @param color Define the lens color
  53889. * @param imgUrl Define the lens texture url
  53890. * @param system Define the `lensFlareSystem` this flare is part of
  53891. */
  53892. constructor(
  53893. /**
  53894. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53895. */
  53896. size: number,
  53897. /**
  53898. * 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.
  53899. */
  53900. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53901. /**
  53902. * Dispose and release the lens flare with its associated resources.
  53903. */
  53904. dispose(): void;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. interface AbstractScene {
  53909. /**
  53910. * The list of lens flare system added to the scene
  53911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53912. */
  53913. lensFlareSystems: Array<LensFlareSystem>;
  53914. /**
  53915. * Removes the given lens flare system from this scene.
  53916. * @param toRemove The lens flare system to remove
  53917. * @returns The index of the removed lens flare system
  53918. */
  53919. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53920. /**
  53921. * Adds the given lens flare system to this scene
  53922. * @param newLensFlareSystem The lens flare system to add
  53923. */
  53924. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53925. /**
  53926. * Gets a lens flare system using its name
  53927. * @param name defines the name to look for
  53928. * @returns the lens flare system or null if not found
  53929. */
  53930. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53931. /**
  53932. * Gets a lens flare system using its id
  53933. * @param id defines the id to look for
  53934. * @returns the lens flare system or null if not found
  53935. */
  53936. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53937. }
  53938. /**
  53939. * Defines the lens flare scene component responsible to manage any lens flares
  53940. * in a given scene.
  53941. */
  53942. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53943. /**
  53944. * The component name helpfull to identify the component in the list of scene components.
  53945. */
  53946. readonly name: string;
  53947. /**
  53948. * The scene the component belongs to.
  53949. */
  53950. scene: Scene;
  53951. /**
  53952. * Creates a new instance of the component for the given scene
  53953. * @param scene Defines the scene to register the component in
  53954. */
  53955. constructor(scene: Scene);
  53956. /**
  53957. * Registers the component in a given scene
  53958. */
  53959. register(): void;
  53960. /**
  53961. * Rebuilds the elements related to this component in case of
  53962. * context lost for instance.
  53963. */
  53964. rebuild(): void;
  53965. /**
  53966. * Adds all the elements from the container to the scene
  53967. * @param container the container holding the elements
  53968. */
  53969. addFromContainer(container: AbstractScene): void;
  53970. /**
  53971. * Removes all the elements in the container from the scene
  53972. * @param container contains the elements to remove
  53973. * @param dispose if the removed element should be disposed (default: false)
  53974. */
  53975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53976. /**
  53977. * Serializes the component data to the specified json object
  53978. * @param serializationObject The object to serialize to
  53979. */
  53980. serialize(serializationObject: any): void;
  53981. /**
  53982. * Disposes the component and the associated ressources.
  53983. */
  53984. dispose(): void;
  53985. private _draw;
  53986. }
  53987. }
  53988. declare module BABYLON {
  53989. /** @hidden */
  53990. export var depthPixelShader: {
  53991. name: string;
  53992. shader: string;
  53993. };
  53994. }
  53995. declare module BABYLON {
  53996. /** @hidden */
  53997. export var depthVertexShader: {
  53998. name: string;
  53999. shader: string;
  54000. };
  54001. }
  54002. declare module BABYLON {
  54003. /**
  54004. * This represents a depth renderer in Babylon.
  54005. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54006. */
  54007. export class DepthRenderer {
  54008. private _scene;
  54009. private _depthMap;
  54010. private _effect;
  54011. private readonly _storeNonLinearDepth;
  54012. private readonly _clearColor;
  54013. /** Get if the depth renderer is using packed depth or not */
  54014. readonly isPacked: boolean;
  54015. private _cachedDefines;
  54016. private _camera;
  54017. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54018. enabled: boolean;
  54019. /**
  54020. * Specifiess that the depth renderer will only be used within
  54021. * the camera it is created for.
  54022. * This can help forcing its rendering during the camera processing.
  54023. */
  54024. useOnlyInActiveCamera: boolean;
  54025. /** @hidden */
  54026. static _SceneComponentInitialization: (scene: Scene) => void;
  54027. /**
  54028. * Instantiates a depth renderer
  54029. * @param scene The scene the renderer belongs to
  54030. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54031. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54032. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54033. */
  54034. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54035. /**
  54036. * Creates the depth rendering effect and checks if the effect is ready.
  54037. * @param subMesh The submesh to be used to render the depth map of
  54038. * @param useInstances If multiple world instances should be used
  54039. * @returns if the depth renderer is ready to render the depth map
  54040. */
  54041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54042. /**
  54043. * Gets the texture which the depth map will be written to.
  54044. * @returns The depth map texture
  54045. */
  54046. getDepthMap(): RenderTargetTexture;
  54047. /**
  54048. * Disposes of the depth renderer.
  54049. */
  54050. dispose(): void;
  54051. }
  54052. }
  54053. declare module BABYLON {
  54054. /** @hidden */
  54055. export var minmaxReduxPixelShader: {
  54056. name: string;
  54057. shader: string;
  54058. };
  54059. }
  54060. declare module BABYLON {
  54061. /**
  54062. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54063. * and maximum values from all values of the texture.
  54064. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54065. * The source values are read from the red channel of the texture.
  54066. */
  54067. export class MinMaxReducer {
  54068. /**
  54069. * Observable triggered when the computation has been performed
  54070. */
  54071. onAfterReductionPerformed: Observable<{
  54072. min: number;
  54073. max: number;
  54074. }>;
  54075. protected _camera: Camera;
  54076. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54077. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54078. protected _postProcessManager: PostProcessManager;
  54079. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54080. protected _forceFullscreenViewport: boolean;
  54081. /**
  54082. * Creates a min/max reducer
  54083. * @param camera The camera to use for the post processes
  54084. */
  54085. constructor(camera: Camera);
  54086. /**
  54087. * Gets the texture used to read the values from.
  54088. */
  54089. get sourceTexture(): Nullable<RenderTargetTexture>;
  54090. /**
  54091. * Sets the source texture to read the values from.
  54092. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54093. * because in such textures '1' value must not be taken into account to compute the maximum
  54094. * as this value is used to clear the texture.
  54095. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54096. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54097. * @param depthRedux Indicates if the texture is a depth texture or not
  54098. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54099. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54100. */
  54101. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54102. /**
  54103. * Defines the refresh rate of the computation.
  54104. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54105. */
  54106. get refreshRate(): number;
  54107. set refreshRate(value: number);
  54108. protected _activated: boolean;
  54109. /**
  54110. * Gets the activation status of the reducer
  54111. */
  54112. get activated(): boolean;
  54113. /**
  54114. * Activates the reduction computation.
  54115. * When activated, the observers registered in onAfterReductionPerformed are
  54116. * called after the compuation is performed
  54117. */
  54118. activate(): void;
  54119. /**
  54120. * Deactivates the reduction computation.
  54121. */
  54122. deactivate(): void;
  54123. /**
  54124. * Disposes the min/max reducer
  54125. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54126. */
  54127. dispose(disposeAll?: boolean): void;
  54128. }
  54129. }
  54130. declare module BABYLON {
  54131. /**
  54132. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54133. */
  54134. export class DepthReducer extends MinMaxReducer {
  54135. private _depthRenderer;
  54136. private _depthRendererId;
  54137. /**
  54138. * Gets the depth renderer used for the computation.
  54139. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54140. */
  54141. get depthRenderer(): Nullable<DepthRenderer>;
  54142. /**
  54143. * Creates a depth reducer
  54144. * @param camera The camera used to render the depth texture
  54145. */
  54146. constructor(camera: Camera);
  54147. /**
  54148. * Sets the depth renderer to use to generate the depth map
  54149. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54150. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54151. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54152. */
  54153. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54154. /** @hidden */
  54155. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54156. /**
  54157. * Activates the reduction computation.
  54158. * When activated, the observers registered in onAfterReductionPerformed are
  54159. * called after the compuation is performed
  54160. */
  54161. activate(): void;
  54162. /**
  54163. * Deactivates the reduction computation.
  54164. */
  54165. deactivate(): void;
  54166. /**
  54167. * Disposes the depth reducer
  54168. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  54169. */
  54170. dispose(disposeAll?: boolean): void;
  54171. }
  54172. }
  54173. declare module BABYLON {
  54174. /**
  54175. * A CSM implementation allowing casting shadows on large scenes.
  54176. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54177. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54178. */
  54179. export class CascadedShadowGenerator extends ShadowGenerator {
  54180. private static readonly frustumCornersNDCSpace;
  54181. /**
  54182. * Name of the CSM class
  54183. */
  54184. static CLASSNAME: string;
  54185. /**
  54186. * Defines the default number of cascades used by the CSM.
  54187. */
  54188. static readonly DEFAULT_CASCADES_COUNT: number;
  54189. /**
  54190. * Defines the minimum number of cascades used by the CSM.
  54191. */
  54192. static readonly MIN_CASCADES_COUNT: number;
  54193. /**
  54194. * Defines the maximum number of cascades used by the CSM.
  54195. */
  54196. static readonly MAX_CASCADES_COUNT: number;
  54197. protected _validateFilter(filter: number): number;
  54198. /**
  54199. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54200. */
  54201. penumbraDarkness: number;
  54202. private _numCascades;
  54203. /**
  54204. * Gets or set the number of cascades used by the CSM.
  54205. */
  54206. get numCascades(): number;
  54207. set numCascades(value: number);
  54208. /**
  54209. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54210. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54211. */
  54212. stabilizeCascades: boolean;
  54213. private _freezeShadowCastersBoundingInfo;
  54214. private _freezeShadowCastersBoundingInfoObservable;
  54215. /**
  54216. * Enables or disables the shadow casters bounding info computation.
  54217. * If your shadow casters don't move, you can disable this feature.
  54218. * If it is enabled, the bounding box computation is done every frame.
  54219. */
  54220. get freezeShadowCastersBoundingInfo(): boolean;
  54221. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54222. private _scbiMin;
  54223. private _scbiMax;
  54224. protected _computeShadowCastersBoundingInfo(): void;
  54225. protected _shadowCastersBoundingInfo: BoundingInfo;
  54226. /**
  54227. * Gets or sets the shadow casters bounding info.
  54228. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54229. * so that the system won't overwrite the bounds you provide
  54230. */
  54231. get shadowCastersBoundingInfo(): BoundingInfo;
  54232. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54233. protected _breaksAreDirty: boolean;
  54234. protected _minDistance: number;
  54235. protected _maxDistance: number;
  54236. /**
  54237. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54238. *
  54239. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54240. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54241. * @param min minimal distance for the breaks (default to 0.)
  54242. * @param max maximal distance for the breaks (default to 1.)
  54243. */
  54244. setMinMaxDistance(min: number, max: number): void;
  54245. /** Gets the minimal distance used in the cascade break computation */
  54246. get minDistance(): number;
  54247. /** Gets the maximal distance used in the cascade break computation */
  54248. get maxDistance(): number;
  54249. /**
  54250. * Gets the class name of that object
  54251. * @returns "CascadedShadowGenerator"
  54252. */
  54253. getClassName(): string;
  54254. private _cascadeMinExtents;
  54255. private _cascadeMaxExtents;
  54256. /**
  54257. * Gets a cascade minimum extents
  54258. * @param cascadeIndex index of the cascade
  54259. * @returns the minimum cascade extents
  54260. */
  54261. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54262. /**
  54263. * Gets a cascade maximum extents
  54264. * @param cascadeIndex index of the cascade
  54265. * @returns the maximum cascade extents
  54266. */
  54267. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54268. private _cascades;
  54269. private _currentLayer;
  54270. private _viewSpaceFrustumsZ;
  54271. private _viewMatrices;
  54272. private _projectionMatrices;
  54273. private _transformMatrices;
  54274. private _transformMatricesAsArray;
  54275. private _frustumLengths;
  54276. private _lightSizeUVCorrection;
  54277. private _depthCorrection;
  54278. private _frustumCornersWorldSpace;
  54279. private _frustumCenter;
  54280. private _shadowCameraPos;
  54281. private _shadowMaxZ;
  54282. /**
  54283. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54284. * It defaults to camera.maxZ
  54285. */
  54286. get shadowMaxZ(): number;
  54287. /**
  54288. * Sets the shadow max z distance.
  54289. */
  54290. set shadowMaxZ(value: number);
  54291. protected _debug: boolean;
  54292. /**
  54293. * Gets or sets the debug flag.
  54294. * When enabled, the cascades are materialized by different colors on the screen.
  54295. */
  54296. get debug(): boolean;
  54297. set debug(dbg: boolean);
  54298. private _depthClamp;
  54299. /**
  54300. * Gets or sets the depth clamping value.
  54301. *
  54302. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54303. * to account for the shadow casters far away.
  54304. *
  54305. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54306. */
  54307. get depthClamp(): boolean;
  54308. set depthClamp(value: boolean);
  54309. private _cascadeBlendPercentage;
  54310. /**
  54311. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54312. * It defaults to 0.1 (10% blending).
  54313. */
  54314. get cascadeBlendPercentage(): number;
  54315. set cascadeBlendPercentage(value: number);
  54316. private _lambda;
  54317. /**
  54318. * Gets or set the lambda parameter.
  54319. * This parameter is used to split the camera frustum and create the cascades.
  54320. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  54321. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54322. */
  54323. get lambda(): number;
  54324. set lambda(value: number);
  54325. /**
  54326. * Gets the view matrix corresponding to a given cascade
  54327. * @param cascadeNum cascade to retrieve the view matrix from
  54328. * @returns the cascade view matrix
  54329. */
  54330. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54331. /**
  54332. * Gets the projection matrix corresponding to a given cascade
  54333. * @param cascadeNum cascade to retrieve the projection matrix from
  54334. * @returns the cascade projection matrix
  54335. */
  54336. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54337. /**
  54338. * Gets the transformation matrix corresponding to a given cascade
  54339. * @param cascadeNum cascade to retrieve the transformation matrix from
  54340. * @returns the cascade transformation matrix
  54341. */
  54342. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54343. private _depthRenderer;
  54344. /**
  54345. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54346. *
  54347. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54348. *
  54349. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54350. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54351. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  54352. */
  54353. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54354. private _depthReducer;
  54355. private _autoCalcDepthBounds;
  54356. /**
  54357. * Gets or sets the autoCalcDepthBounds property.
  54358. *
  54359. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54360. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54361. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54362. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54363. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54364. */
  54365. get autoCalcDepthBounds(): boolean;
  54366. set autoCalcDepthBounds(value: boolean);
  54367. /**
  54368. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54369. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54370. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54371. * for setting the refresh rate on the renderer yourself!
  54372. */
  54373. get autoCalcDepthBoundsRefreshRate(): number;
  54374. set autoCalcDepthBoundsRefreshRate(value: number);
  54375. /**
  54376. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54377. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54378. * you change the camera near/far planes!
  54379. */
  54380. splitFrustum(): void;
  54381. private _splitFrustum;
  54382. private _computeMatrices;
  54383. private _computeFrustumInWorldSpace;
  54384. private _computeCascadeFrustum;
  54385. /** @hidden */
  54386. static _SceneComponentInitialization: (scene: Scene) => void;
  54387. /**
  54388. * Creates a Cascaded Shadow Generator object.
  54389. * A ShadowGenerator is the required tool to use the shadows.
  54390. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54391. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54392. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54393. * @param light The directional light object generating the shadows.
  54394. * @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.
  54395. */
  54396. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54397. protected _initializeGenerator(): void;
  54398. protected _createTargetRenderTexture(): void;
  54399. protected _initializeShadowMap(): void;
  54400. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54401. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54402. /**
  54403. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54404. * @param defines Defines of the material we want to update
  54405. * @param lightIndex Index of the light in the enabled light list of the material
  54406. */
  54407. prepareDefines(defines: any, lightIndex: number): void;
  54408. /**
  54409. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54410. * defined in the generator but impacting the effect).
  54411. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54412. * @param effect The effect we are binfing the information for
  54413. */
  54414. bindShadowLight(lightIndex: string, effect: Effect): void;
  54415. /**
  54416. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54417. * (eq to view projection * shadow projection matrices)
  54418. * @returns The transform matrix used to create the shadow map
  54419. */
  54420. getTransformMatrix(): Matrix;
  54421. /**
  54422. * Disposes the ShadowGenerator.
  54423. * Returns nothing.
  54424. */
  54425. dispose(): void;
  54426. /**
  54427. * Serializes the shadow generator setup to a json object.
  54428. * @returns The serialized JSON object
  54429. */
  54430. serialize(): any;
  54431. /**
  54432. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54433. * @param parsedShadowGenerator The JSON object to parse
  54434. * @param scene The scene to create the shadow map for
  54435. * @returns The parsed shadow generator
  54436. */
  54437. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54438. }
  54439. }
  54440. declare module BABYLON {
  54441. /**
  54442. * Defines the shadow generator component responsible to manage any shadow generators
  54443. * in a given scene.
  54444. */
  54445. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54446. /**
  54447. * The component name helpfull to identify the component in the list of scene components.
  54448. */
  54449. readonly name: string;
  54450. /**
  54451. * The scene the component belongs to.
  54452. */
  54453. scene: Scene;
  54454. /**
  54455. * Creates a new instance of the component for the given scene
  54456. * @param scene Defines the scene to register the component in
  54457. */
  54458. constructor(scene: Scene);
  54459. /**
  54460. * Registers the component in a given scene
  54461. */
  54462. register(): void;
  54463. /**
  54464. * Rebuilds the elements related to this component in case of
  54465. * context lost for instance.
  54466. */
  54467. rebuild(): void;
  54468. /**
  54469. * Serializes the component data to the specified json object
  54470. * @param serializationObject The object to serialize to
  54471. */
  54472. serialize(serializationObject: any): void;
  54473. /**
  54474. * Adds all the elements from the container to the scene
  54475. * @param container the container holding the elements
  54476. */
  54477. addFromContainer(container: AbstractScene): void;
  54478. /**
  54479. * Removes all the elements in the container from the scene
  54480. * @param container contains the elements to remove
  54481. * @param dispose if the removed element should be disposed (default: false)
  54482. */
  54483. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54484. /**
  54485. * Rebuilds the elements related to this component in case of
  54486. * context lost for instance.
  54487. */
  54488. dispose(): void;
  54489. private _gatherRenderTargets;
  54490. }
  54491. }
  54492. declare module BABYLON {
  54493. /**
  54494. * A point light is a light defined by an unique point in world space.
  54495. * The light is emitted in every direction from this point.
  54496. * A good example of a point light is a standard light bulb.
  54497. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54498. */
  54499. export class PointLight extends ShadowLight {
  54500. private _shadowAngle;
  54501. /**
  54502. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54503. * This specifies what angle the shadow will use to be created.
  54504. *
  54505. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54506. */
  54507. get shadowAngle(): number;
  54508. /**
  54509. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54510. * This specifies what angle the shadow will use to be created.
  54511. *
  54512. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54513. */
  54514. set shadowAngle(value: number);
  54515. /**
  54516. * Gets the direction if it has been set.
  54517. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54518. */
  54519. get direction(): Vector3;
  54520. /**
  54521. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54522. */
  54523. set direction(value: Vector3);
  54524. /**
  54525. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54526. * A PointLight emits the light in every direction.
  54527. * It can cast shadows.
  54528. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54529. * ```javascript
  54530. * var pointLight = new PointLight("pl", camera.position, scene);
  54531. * ```
  54532. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54533. * @param name The light friendly name
  54534. * @param position The position of the point light in the scene
  54535. * @param scene The scene the lights belongs to
  54536. */
  54537. constructor(name: string, position: Vector3, scene: Scene);
  54538. /**
  54539. * Returns the string "PointLight"
  54540. * @returns the class name
  54541. */
  54542. getClassName(): string;
  54543. /**
  54544. * Returns the integer 0.
  54545. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54546. */
  54547. getTypeID(): number;
  54548. /**
  54549. * Specifies wether or not the shadowmap should be a cube texture.
  54550. * @returns true if the shadowmap needs to be a cube texture.
  54551. */
  54552. needCube(): boolean;
  54553. /**
  54554. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54555. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54556. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54557. */
  54558. getShadowDirection(faceIndex?: number): Vector3;
  54559. /**
  54560. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54561. * - fov = PI / 2
  54562. * - aspect ratio : 1.0
  54563. * - z-near and far equal to the active camera minZ and maxZ.
  54564. * Returns the PointLight.
  54565. */
  54566. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54567. protected _buildUniformLayout(): void;
  54568. /**
  54569. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54570. * @param effect The effect to update
  54571. * @param lightIndex The index of the light in the effect to update
  54572. * @returns The point light
  54573. */
  54574. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54575. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54576. /**
  54577. * Prepares the list of defines specific to the light type.
  54578. * @param defines the list of defines
  54579. * @param lightIndex defines the index of the light for the effect
  54580. */
  54581. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54582. }
  54583. }
  54584. declare module BABYLON {
  54585. /**
  54586. * Header information of HDR texture files.
  54587. */
  54588. export interface HDRInfo {
  54589. /**
  54590. * The height of the texture in pixels.
  54591. */
  54592. height: number;
  54593. /**
  54594. * The width of the texture in pixels.
  54595. */
  54596. width: number;
  54597. /**
  54598. * The index of the beginning of the data in the binary file.
  54599. */
  54600. dataPosition: number;
  54601. }
  54602. /**
  54603. * This groups tools to convert HDR texture to native colors array.
  54604. */
  54605. export class HDRTools {
  54606. private static Ldexp;
  54607. private static Rgbe2float;
  54608. private static readStringLine;
  54609. /**
  54610. * Reads header information from an RGBE texture stored in a native array.
  54611. * More information on this format are available here:
  54612. * https://en.wikipedia.org/wiki/RGBE_image_format
  54613. *
  54614. * @param uint8array The binary file stored in native array.
  54615. * @return The header information.
  54616. */
  54617. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54618. /**
  54619. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54620. * This RGBE texture needs to store the information as a panorama.
  54621. *
  54622. * More information on this format are available here:
  54623. * https://en.wikipedia.org/wiki/RGBE_image_format
  54624. *
  54625. * @param buffer The binary file stored in an array buffer.
  54626. * @param size The expected size of the extracted cubemap.
  54627. * @return The Cube Map information.
  54628. */
  54629. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54630. /**
  54631. * Returns the pixels data extracted from an RGBE texture.
  54632. * This pixels will be stored left to right up to down in the R G B order in one array.
  54633. *
  54634. * More information on this format are available here:
  54635. * https://en.wikipedia.org/wiki/RGBE_image_format
  54636. *
  54637. * @param uint8array The binary file stored in an array buffer.
  54638. * @param hdrInfo The header information of the file.
  54639. * @return The pixels data in RGB right to left up to down order.
  54640. */
  54641. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54642. private static RGBE_ReadPixels_RLE;
  54643. }
  54644. }
  54645. declare module BABYLON {
  54646. /**
  54647. * This represents a texture coming from an HDR input.
  54648. *
  54649. * The only supported format is currently panorama picture stored in RGBE format.
  54650. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54651. */
  54652. export class HDRCubeTexture extends BaseTexture {
  54653. private static _facesMapping;
  54654. private _generateHarmonics;
  54655. private _noMipmap;
  54656. private _textureMatrix;
  54657. private _size;
  54658. private _onLoad;
  54659. private _onError;
  54660. /**
  54661. * The texture URL.
  54662. */
  54663. url: string;
  54664. /**
  54665. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54666. */
  54667. coordinatesMode: number;
  54668. protected _isBlocking: boolean;
  54669. /**
  54670. * Sets wether or not the texture is blocking during loading.
  54671. */
  54672. set isBlocking(value: boolean);
  54673. /**
  54674. * Gets wether or not the texture is blocking during loading.
  54675. */
  54676. get isBlocking(): boolean;
  54677. protected _rotationY: number;
  54678. /**
  54679. * Sets texture matrix rotation angle around Y axis in radians.
  54680. */
  54681. set rotationY(value: number);
  54682. /**
  54683. * Gets texture matrix rotation angle around Y axis radians.
  54684. */
  54685. get rotationY(): number;
  54686. /**
  54687. * Gets or sets the center of the bounding box associated with the cube texture
  54688. * It must define where the camera used to render the texture was set
  54689. */
  54690. boundingBoxPosition: Vector3;
  54691. private _boundingBoxSize;
  54692. /**
  54693. * Gets or sets the size of the bounding box associated with the cube texture
  54694. * When defined, the cubemap will switch to local mode
  54695. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54696. * @example https://www.babylonjs-playground.com/#RNASML
  54697. */
  54698. set boundingBoxSize(value: Vector3);
  54699. get boundingBoxSize(): Vector3;
  54700. /**
  54701. * Instantiates an HDRTexture from the following parameters.
  54702. *
  54703. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54704. * @param scene The scene the texture will be used in
  54705. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54706. * @param noMipmap Forces to not generate the mipmap if true
  54707. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54708. * @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)
  54709. * @param reserved Reserved flag for internal use.
  54710. */
  54711. 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>);
  54712. /**
  54713. * Get the current class name of the texture useful for serialization or dynamic coding.
  54714. * @returns "HDRCubeTexture"
  54715. */
  54716. getClassName(): string;
  54717. /**
  54718. * Occurs when the file is raw .hdr file.
  54719. */
  54720. private loadTexture;
  54721. clone(): HDRCubeTexture;
  54722. delayLoad(): void;
  54723. /**
  54724. * Get the texture reflection matrix used to rotate/transform the reflection.
  54725. * @returns the reflection matrix
  54726. */
  54727. getReflectionTextureMatrix(): Matrix;
  54728. /**
  54729. * Set the texture reflection matrix used to rotate/transform the reflection.
  54730. * @param value Define the reflection matrix to set
  54731. */
  54732. setReflectionTextureMatrix(value: Matrix): void;
  54733. /**
  54734. * Parses a JSON representation of an HDR Texture in order to create the texture
  54735. * @param parsedTexture Define the JSON representation
  54736. * @param scene Define the scene the texture should be created in
  54737. * @param rootUrl Define the root url in case we need to load relative dependencies
  54738. * @returns the newly created texture after parsing
  54739. */
  54740. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54741. serialize(): any;
  54742. }
  54743. }
  54744. declare module BABYLON {
  54745. /**
  54746. * Class used to control physics engine
  54747. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54748. */
  54749. export class PhysicsEngine implements IPhysicsEngine {
  54750. private _physicsPlugin;
  54751. /**
  54752. * Global value used to control the smallest number supported by the simulation
  54753. */
  54754. static Epsilon: number;
  54755. private _impostors;
  54756. private _joints;
  54757. private _subTimeStep;
  54758. /**
  54759. * Gets the gravity vector used by the simulation
  54760. */
  54761. gravity: Vector3;
  54762. /**
  54763. * Factory used to create the default physics plugin.
  54764. * @returns The default physics plugin
  54765. */
  54766. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54767. /**
  54768. * Creates a new Physics Engine
  54769. * @param gravity defines the gravity vector used by the simulation
  54770. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54771. */
  54772. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54773. /**
  54774. * Sets the gravity vector used by the simulation
  54775. * @param gravity defines the gravity vector to use
  54776. */
  54777. setGravity(gravity: Vector3): void;
  54778. /**
  54779. * Set the time step of the physics engine.
  54780. * Default is 1/60.
  54781. * To slow it down, enter 1/600 for example.
  54782. * To speed it up, 1/30
  54783. * @param newTimeStep defines the new timestep to apply to this world.
  54784. */
  54785. setTimeStep(newTimeStep?: number): void;
  54786. /**
  54787. * Get the time step of the physics engine.
  54788. * @returns the current time step
  54789. */
  54790. getTimeStep(): number;
  54791. /**
  54792. * Set the sub time step of the physics engine.
  54793. * Default is 0 meaning there is no sub steps
  54794. * To increase physics resolution precision, set a small value (like 1 ms)
  54795. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54796. */
  54797. setSubTimeStep(subTimeStep?: number): void;
  54798. /**
  54799. * Get the sub time step of the physics engine.
  54800. * @returns the current sub time step
  54801. */
  54802. getSubTimeStep(): number;
  54803. /**
  54804. * Release all resources
  54805. */
  54806. dispose(): void;
  54807. /**
  54808. * Gets the name of the current physics plugin
  54809. * @returns the name of the plugin
  54810. */
  54811. getPhysicsPluginName(): string;
  54812. /**
  54813. * Adding a new impostor for the impostor tracking.
  54814. * This will be done by the impostor itself.
  54815. * @param impostor the impostor to add
  54816. */
  54817. addImpostor(impostor: PhysicsImpostor): void;
  54818. /**
  54819. * Remove an impostor from the engine.
  54820. * This impostor and its mesh will not longer be updated by the physics engine.
  54821. * @param impostor the impostor to remove
  54822. */
  54823. removeImpostor(impostor: PhysicsImpostor): void;
  54824. /**
  54825. * Add a joint to the physics engine
  54826. * @param mainImpostor defines the main impostor to which the joint is added.
  54827. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54828. * @param joint defines the joint that will connect both impostors.
  54829. */
  54830. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54831. /**
  54832. * Removes a joint from the simulation
  54833. * @param mainImpostor defines the impostor used with the joint
  54834. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54835. * @param joint defines the joint to remove
  54836. */
  54837. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54838. /**
  54839. * Called by the scene. No need to call it.
  54840. * @param delta defines the timespam between frames
  54841. */
  54842. _step(delta: number): void;
  54843. /**
  54844. * Gets the current plugin used to run the simulation
  54845. * @returns current plugin
  54846. */
  54847. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54848. /**
  54849. * Gets the list of physic impostors
  54850. * @returns an array of PhysicsImpostor
  54851. */
  54852. getImpostors(): Array<PhysicsImpostor>;
  54853. /**
  54854. * Gets the impostor for a physics enabled object
  54855. * @param object defines the object impersonated by the impostor
  54856. * @returns the PhysicsImpostor or null if not found
  54857. */
  54858. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54859. /**
  54860. * Gets the impostor for a physics body object
  54861. * @param body defines physics body used by the impostor
  54862. * @returns the PhysicsImpostor or null if not found
  54863. */
  54864. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54865. /**
  54866. * Does a raycast in the physics world
  54867. * @param from when should the ray start?
  54868. * @param to when should the ray end?
  54869. * @returns PhysicsRaycastResult
  54870. */
  54871. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54872. }
  54873. }
  54874. declare module BABYLON {
  54875. /** @hidden */
  54876. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54877. private _useDeltaForWorldStep;
  54878. world: any;
  54879. name: string;
  54880. private _physicsMaterials;
  54881. private _fixedTimeStep;
  54882. private _cannonRaycastResult;
  54883. private _raycastResult;
  54884. private _physicsBodysToRemoveAfterStep;
  54885. BJSCANNON: any;
  54886. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54887. setGravity(gravity: Vector3): void;
  54888. setTimeStep(timeStep: number): void;
  54889. getTimeStep(): number;
  54890. executeStep(delta: number): void;
  54891. private _removeMarkedPhysicsBodiesFromWorld;
  54892. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54893. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54894. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54895. private _processChildMeshes;
  54896. removePhysicsBody(impostor: PhysicsImpostor): void;
  54897. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54898. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54899. private _addMaterial;
  54900. private _checkWithEpsilon;
  54901. private _createShape;
  54902. private _createHeightmap;
  54903. private _minus90X;
  54904. private _plus90X;
  54905. private _tmpPosition;
  54906. private _tmpDeltaPosition;
  54907. private _tmpUnityRotation;
  54908. private _updatePhysicsBodyTransformation;
  54909. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54910. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54911. isSupported(): boolean;
  54912. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54913. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54914. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54915. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54916. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54917. getBodyMass(impostor: PhysicsImpostor): number;
  54918. getBodyFriction(impostor: PhysicsImpostor): number;
  54919. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54920. getBodyRestitution(impostor: PhysicsImpostor): number;
  54921. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54922. sleepBody(impostor: PhysicsImpostor): void;
  54923. wakeUpBody(impostor: PhysicsImpostor): void;
  54924. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54925. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54926. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54927. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54928. getRadius(impostor: PhysicsImpostor): number;
  54929. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54930. dispose(): void;
  54931. private _extendNamespace;
  54932. /**
  54933. * Does a raycast in the physics world
  54934. * @param from when should the ray start?
  54935. * @param to when should the ray end?
  54936. * @returns PhysicsRaycastResult
  54937. */
  54938. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54939. }
  54940. }
  54941. declare module BABYLON {
  54942. /** @hidden */
  54943. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54944. world: any;
  54945. name: string;
  54946. BJSOIMO: any;
  54947. private _raycastResult;
  54948. constructor(iterations?: number, oimoInjection?: any);
  54949. setGravity(gravity: Vector3): void;
  54950. setTimeStep(timeStep: number): void;
  54951. getTimeStep(): number;
  54952. private _tmpImpostorsArray;
  54953. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54954. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54955. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54956. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54957. private _tmpPositionVector;
  54958. removePhysicsBody(impostor: PhysicsImpostor): void;
  54959. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54960. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54961. isSupported(): boolean;
  54962. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54963. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54964. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54965. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54966. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54967. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54968. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54969. getBodyMass(impostor: PhysicsImpostor): number;
  54970. getBodyFriction(impostor: PhysicsImpostor): number;
  54971. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54972. getBodyRestitution(impostor: PhysicsImpostor): number;
  54973. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54974. sleepBody(impostor: PhysicsImpostor): void;
  54975. wakeUpBody(impostor: PhysicsImpostor): void;
  54976. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54977. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54978. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54979. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54980. getRadius(impostor: PhysicsImpostor): number;
  54981. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54982. dispose(): void;
  54983. /**
  54984. * Does a raycast in the physics world
  54985. * @param from when should the ray start?
  54986. * @param to when should the ray end?
  54987. * @returns PhysicsRaycastResult
  54988. */
  54989. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54990. }
  54991. }
  54992. declare module BABYLON {
  54993. /**
  54994. * Class containing static functions to help procedurally build meshes
  54995. */
  54996. export class RibbonBuilder {
  54997. /**
  54998. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54999. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55000. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55001. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55002. * * 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
  55003. * * 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
  55004. * * 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
  55005. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55006. * * 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
  55007. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55008. * * 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
  55009. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55010. * * 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
  55011. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55013. * @param name defines the name of the mesh
  55014. * @param options defines the options used to create the mesh
  55015. * @param scene defines the hosting scene
  55016. * @returns the ribbon mesh
  55017. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55018. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55019. */
  55020. static CreateRibbon(name: string, options: {
  55021. pathArray: Vector3[][];
  55022. closeArray?: boolean;
  55023. closePath?: boolean;
  55024. offset?: number;
  55025. updatable?: boolean;
  55026. sideOrientation?: number;
  55027. frontUVs?: Vector4;
  55028. backUVs?: Vector4;
  55029. instance?: Mesh;
  55030. invertUV?: boolean;
  55031. uvs?: Vector2[];
  55032. colors?: Color4[];
  55033. }, scene?: Nullable<Scene>): Mesh;
  55034. }
  55035. }
  55036. declare module BABYLON {
  55037. /**
  55038. * Class containing static functions to help procedurally build meshes
  55039. */
  55040. export class ShapeBuilder {
  55041. /**
  55042. * 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.
  55043. * * 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.
  55044. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55045. * * 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.
  55046. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55047. * * 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
  55048. * * 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
  55049. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55050. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55051. * * 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
  55052. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55053. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55054. * @param name defines the name of the mesh
  55055. * @param options defines the options used to create the mesh
  55056. * @param scene defines the hosting scene
  55057. * @returns the extruded shape mesh
  55058. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55060. */
  55061. static ExtrudeShape(name: string, options: {
  55062. shape: Vector3[];
  55063. path: Vector3[];
  55064. scale?: number;
  55065. rotation?: number;
  55066. cap?: number;
  55067. updatable?: boolean;
  55068. sideOrientation?: number;
  55069. frontUVs?: Vector4;
  55070. backUVs?: Vector4;
  55071. instance?: Mesh;
  55072. invertUV?: boolean;
  55073. }, scene?: Nullable<Scene>): Mesh;
  55074. /**
  55075. * Creates an custom extruded shape mesh.
  55076. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55077. * * 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.
  55078. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55079. * * 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
  55080. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55081. * * 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
  55082. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55083. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55084. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55085. * * 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
  55086. * * 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
  55087. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55089. * * 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
  55090. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55092. * @param name defines the name of the mesh
  55093. * @param options defines the options used to create the mesh
  55094. * @param scene defines the hosting scene
  55095. * @returns the custom extruded shape mesh
  55096. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55097. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55098. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55099. */
  55100. static ExtrudeShapeCustom(name: string, options: {
  55101. shape: Vector3[];
  55102. path: Vector3[];
  55103. scaleFunction?: any;
  55104. rotationFunction?: any;
  55105. ribbonCloseArray?: boolean;
  55106. ribbonClosePath?: boolean;
  55107. cap?: number;
  55108. updatable?: boolean;
  55109. sideOrientation?: number;
  55110. frontUVs?: Vector4;
  55111. backUVs?: Vector4;
  55112. instance?: Mesh;
  55113. invertUV?: boolean;
  55114. }, scene?: Nullable<Scene>): Mesh;
  55115. private static _ExtrudeShapeGeneric;
  55116. }
  55117. }
  55118. declare module BABYLON {
  55119. /**
  55120. * AmmoJS Physics plugin
  55121. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55122. * @see https://github.com/kripken/ammo.js/
  55123. */
  55124. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55125. private _useDeltaForWorldStep;
  55126. /**
  55127. * Reference to the Ammo library
  55128. */
  55129. bjsAMMO: any;
  55130. /**
  55131. * Created ammoJS world which physics bodies are added to
  55132. */
  55133. world: any;
  55134. /**
  55135. * Name of the plugin
  55136. */
  55137. name: string;
  55138. private _timeStep;
  55139. private _fixedTimeStep;
  55140. private _maxSteps;
  55141. private _tmpQuaternion;
  55142. private _tmpAmmoTransform;
  55143. private _tmpAmmoQuaternion;
  55144. private _tmpAmmoConcreteContactResultCallback;
  55145. private _collisionConfiguration;
  55146. private _dispatcher;
  55147. private _overlappingPairCache;
  55148. private _solver;
  55149. private _softBodySolver;
  55150. private _tmpAmmoVectorA;
  55151. private _tmpAmmoVectorB;
  55152. private _tmpAmmoVectorC;
  55153. private _tmpAmmoVectorD;
  55154. private _tmpContactCallbackResult;
  55155. private _tmpAmmoVectorRCA;
  55156. private _tmpAmmoVectorRCB;
  55157. private _raycastResult;
  55158. private static readonly DISABLE_COLLISION_FLAG;
  55159. private static readonly KINEMATIC_FLAG;
  55160. private static readonly DISABLE_DEACTIVATION_FLAG;
  55161. /**
  55162. * Initializes the ammoJS plugin
  55163. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55164. * @param ammoInjection can be used to inject your own ammo reference
  55165. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55166. */
  55167. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55168. /**
  55169. * Sets the gravity of the physics world (m/(s^2))
  55170. * @param gravity Gravity to set
  55171. */
  55172. setGravity(gravity: Vector3): void;
  55173. /**
  55174. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55175. * @param timeStep timestep to use in seconds
  55176. */
  55177. setTimeStep(timeStep: number): void;
  55178. /**
  55179. * 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)
  55180. * @param fixedTimeStep fixedTimeStep to use in seconds
  55181. */
  55182. setFixedTimeStep(fixedTimeStep: number): void;
  55183. /**
  55184. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55185. * @param maxSteps the maximum number of steps by the physics engine per frame
  55186. */
  55187. setMaxSteps(maxSteps: number): void;
  55188. /**
  55189. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55190. * @returns the current timestep in seconds
  55191. */
  55192. getTimeStep(): number;
  55193. /**
  55194. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55195. */
  55196. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55197. private _isImpostorInContact;
  55198. private _isImpostorPairInContact;
  55199. private _stepSimulation;
  55200. /**
  55201. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55202. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55203. * After the step the babylon meshes are set to the position of the physics imposters
  55204. * @param delta amount of time to step forward
  55205. * @param impostors array of imposters to update before/after the step
  55206. */
  55207. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55208. /**
  55209. * Update babylon mesh to match physics world object
  55210. * @param impostor imposter to match
  55211. */
  55212. private _afterSoftStep;
  55213. /**
  55214. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55215. * @param impostor imposter to match
  55216. */
  55217. private _ropeStep;
  55218. /**
  55219. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55220. * @param impostor imposter to match
  55221. */
  55222. private _softbodyOrClothStep;
  55223. private _tmpVector;
  55224. private _tmpMatrix;
  55225. /**
  55226. * Applies an impulse on the imposter
  55227. * @param impostor imposter to apply impulse to
  55228. * @param force amount of force to be applied to the imposter
  55229. * @param contactPoint the location to apply the impulse on the imposter
  55230. */
  55231. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55232. /**
  55233. * Applies a force on the imposter
  55234. * @param impostor imposter to apply force
  55235. * @param force amount of force to be applied to the imposter
  55236. * @param contactPoint the location to apply the force on the imposter
  55237. */
  55238. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55239. /**
  55240. * Creates a physics body using the plugin
  55241. * @param impostor the imposter to create the physics body on
  55242. */
  55243. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55244. /**
  55245. * Removes the physics body from the imposter and disposes of the body's memory
  55246. * @param impostor imposter to remove the physics body from
  55247. */
  55248. removePhysicsBody(impostor: PhysicsImpostor): void;
  55249. /**
  55250. * Generates a joint
  55251. * @param impostorJoint the imposter joint to create the joint with
  55252. */
  55253. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55254. /**
  55255. * Removes a joint
  55256. * @param impostorJoint the imposter joint to remove the joint from
  55257. */
  55258. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55259. private _addMeshVerts;
  55260. /**
  55261. * Initialise the soft body vertices to match its object's (mesh) vertices
  55262. * Softbody vertices (nodes) are in world space and to match this
  55263. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55264. * @param impostor to create the softbody for
  55265. */
  55266. private _softVertexData;
  55267. /**
  55268. * Create an impostor's soft body
  55269. * @param impostor to create the softbody for
  55270. */
  55271. private _createSoftbody;
  55272. /**
  55273. * Create cloth for an impostor
  55274. * @param impostor to create the softbody for
  55275. */
  55276. private _createCloth;
  55277. /**
  55278. * Create rope for an impostor
  55279. * @param impostor to create the softbody for
  55280. */
  55281. private _createRope;
  55282. /**
  55283. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55284. * @param impostor to create the custom physics shape for
  55285. */
  55286. private _createCustom;
  55287. private _addHullVerts;
  55288. private _createShape;
  55289. /**
  55290. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55291. * @param impostor imposter containing the physics body and babylon object
  55292. */
  55293. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55294. /**
  55295. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55296. * @param impostor imposter containing the physics body and babylon object
  55297. * @param newPosition new position
  55298. * @param newRotation new rotation
  55299. */
  55300. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55301. /**
  55302. * If this plugin is supported
  55303. * @returns true if its supported
  55304. */
  55305. isSupported(): boolean;
  55306. /**
  55307. * Sets the linear velocity of the physics body
  55308. * @param impostor imposter to set the velocity on
  55309. * @param velocity velocity to set
  55310. */
  55311. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55312. /**
  55313. * Sets the angular velocity of the physics body
  55314. * @param impostor imposter to set the velocity on
  55315. * @param velocity velocity to set
  55316. */
  55317. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55318. /**
  55319. * gets the linear velocity
  55320. * @param impostor imposter to get linear velocity from
  55321. * @returns linear velocity
  55322. */
  55323. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55324. /**
  55325. * gets the angular velocity
  55326. * @param impostor imposter to get angular velocity from
  55327. * @returns angular velocity
  55328. */
  55329. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55330. /**
  55331. * Sets the mass of physics body
  55332. * @param impostor imposter to set the mass on
  55333. * @param mass mass to set
  55334. */
  55335. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55336. /**
  55337. * Gets the mass of the physics body
  55338. * @param impostor imposter to get the mass from
  55339. * @returns mass
  55340. */
  55341. getBodyMass(impostor: PhysicsImpostor): number;
  55342. /**
  55343. * Gets friction of the impostor
  55344. * @param impostor impostor to get friction from
  55345. * @returns friction value
  55346. */
  55347. getBodyFriction(impostor: PhysicsImpostor): number;
  55348. /**
  55349. * Sets friction of the impostor
  55350. * @param impostor impostor to set friction on
  55351. * @param friction friction value
  55352. */
  55353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55354. /**
  55355. * Gets restitution of the impostor
  55356. * @param impostor impostor to get restitution from
  55357. * @returns restitution value
  55358. */
  55359. getBodyRestitution(impostor: PhysicsImpostor): number;
  55360. /**
  55361. * Sets resitution of the impostor
  55362. * @param impostor impostor to set resitution on
  55363. * @param restitution resitution value
  55364. */
  55365. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55366. /**
  55367. * Gets pressure inside the impostor
  55368. * @param impostor impostor to get pressure from
  55369. * @returns pressure value
  55370. */
  55371. getBodyPressure(impostor: PhysicsImpostor): number;
  55372. /**
  55373. * Sets pressure inside a soft body impostor
  55374. * Cloth and rope must remain 0 pressure
  55375. * @param impostor impostor to set pressure on
  55376. * @param pressure pressure value
  55377. */
  55378. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55379. /**
  55380. * Gets stiffness of the impostor
  55381. * @param impostor impostor to get stiffness from
  55382. * @returns pressure value
  55383. */
  55384. getBodyStiffness(impostor: PhysicsImpostor): number;
  55385. /**
  55386. * Sets stiffness of the impostor
  55387. * @param impostor impostor to set stiffness on
  55388. * @param stiffness stiffness value from 0 to 1
  55389. */
  55390. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55391. /**
  55392. * Gets velocityIterations of the impostor
  55393. * @param impostor impostor to get velocity iterations from
  55394. * @returns velocityIterations value
  55395. */
  55396. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55397. /**
  55398. * Sets velocityIterations of the impostor
  55399. * @param impostor impostor to set velocity iterations on
  55400. * @param velocityIterations velocityIterations value
  55401. */
  55402. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55403. /**
  55404. * Gets positionIterations of the impostor
  55405. * @param impostor impostor to get position iterations from
  55406. * @returns positionIterations value
  55407. */
  55408. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55409. /**
  55410. * Sets positionIterations of the impostor
  55411. * @param impostor impostor to set position on
  55412. * @param positionIterations positionIterations value
  55413. */
  55414. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55415. /**
  55416. * Append an anchor to a cloth object
  55417. * @param impostor is the cloth impostor to add anchor to
  55418. * @param otherImpostor is the rigid impostor to anchor to
  55419. * @param width ratio across width from 0 to 1
  55420. * @param height ratio up height from 0 to 1
  55421. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55422. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55423. */
  55424. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55425. /**
  55426. * Append an hook to a rope object
  55427. * @param impostor is the rope impostor to add hook to
  55428. * @param otherImpostor is the rigid impostor to hook to
  55429. * @param length ratio along the rope from 0 to 1
  55430. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55431. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55432. */
  55433. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55434. /**
  55435. * Sleeps the physics body and stops it from being active
  55436. * @param impostor impostor to sleep
  55437. */
  55438. sleepBody(impostor: PhysicsImpostor): void;
  55439. /**
  55440. * Activates the physics body
  55441. * @param impostor impostor to activate
  55442. */
  55443. wakeUpBody(impostor: PhysicsImpostor): void;
  55444. /**
  55445. * Updates the distance parameters of the joint
  55446. * @param joint joint to update
  55447. * @param maxDistance maximum distance of the joint
  55448. * @param minDistance minimum distance of the joint
  55449. */
  55450. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55451. /**
  55452. * Sets a motor on the joint
  55453. * @param joint joint to set motor on
  55454. * @param speed speed of the motor
  55455. * @param maxForce maximum force of the motor
  55456. * @param motorIndex index of the motor
  55457. */
  55458. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55459. /**
  55460. * Sets the motors limit
  55461. * @param joint joint to set limit on
  55462. * @param upperLimit upper limit
  55463. * @param lowerLimit lower limit
  55464. */
  55465. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55466. /**
  55467. * Syncs the position and rotation of a mesh with the impostor
  55468. * @param mesh mesh to sync
  55469. * @param impostor impostor to update the mesh with
  55470. */
  55471. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55472. /**
  55473. * Gets the radius of the impostor
  55474. * @param impostor impostor to get radius from
  55475. * @returns the radius
  55476. */
  55477. getRadius(impostor: PhysicsImpostor): number;
  55478. /**
  55479. * Gets the box size of the impostor
  55480. * @param impostor impostor to get box size from
  55481. * @param result the resulting box size
  55482. */
  55483. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55484. /**
  55485. * Disposes of the impostor
  55486. */
  55487. dispose(): void;
  55488. /**
  55489. * Does a raycast in the physics world
  55490. * @param from when should the ray start?
  55491. * @param to when should the ray end?
  55492. * @returns PhysicsRaycastResult
  55493. */
  55494. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55495. }
  55496. }
  55497. declare module BABYLON {
  55498. interface AbstractScene {
  55499. /**
  55500. * The list of reflection probes added to the scene
  55501. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55502. */
  55503. reflectionProbes: Array<ReflectionProbe>;
  55504. /**
  55505. * Removes the given reflection probe from this scene.
  55506. * @param toRemove The reflection probe to remove
  55507. * @returns The index of the removed reflection probe
  55508. */
  55509. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55510. /**
  55511. * Adds the given reflection probe to this scene.
  55512. * @param newReflectionProbe The reflection probe to add
  55513. */
  55514. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55515. }
  55516. /**
  55517. * Class used to generate realtime reflection / refraction cube textures
  55518. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55519. */
  55520. export class ReflectionProbe {
  55521. /** defines the name of the probe */
  55522. name: string;
  55523. private _scene;
  55524. private _renderTargetTexture;
  55525. private _projectionMatrix;
  55526. private _viewMatrix;
  55527. private _target;
  55528. private _add;
  55529. private _attachedMesh;
  55530. private _invertYAxis;
  55531. /** Gets or sets probe position (center of the cube map) */
  55532. position: Vector3;
  55533. /**
  55534. * Creates a new reflection probe
  55535. * @param name defines the name of the probe
  55536. * @param size defines the texture resolution (for each face)
  55537. * @param scene defines the hosting scene
  55538. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55539. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55540. */
  55541. constructor(
  55542. /** defines the name of the probe */
  55543. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55544. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55545. get samples(): number;
  55546. set samples(value: number);
  55547. /** Gets or sets the refresh rate to use (on every frame by default) */
  55548. get refreshRate(): number;
  55549. set refreshRate(value: number);
  55550. /**
  55551. * Gets the hosting scene
  55552. * @returns a Scene
  55553. */
  55554. getScene(): Scene;
  55555. /** Gets the internal CubeTexture used to render to */
  55556. get cubeTexture(): RenderTargetTexture;
  55557. /** Gets the list of meshes to render */
  55558. get renderList(): Nullable<AbstractMesh[]>;
  55559. /**
  55560. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55561. * @param mesh defines the mesh to attach to
  55562. */
  55563. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55564. /**
  55565. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55566. * @param renderingGroupId The rendering group id corresponding to its index
  55567. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55568. */
  55569. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55570. /**
  55571. * Clean all associated resources
  55572. */
  55573. dispose(): void;
  55574. /**
  55575. * Converts the reflection probe information to a readable string for debug purpose.
  55576. * @param fullDetails Supports for multiple levels of logging within scene loading
  55577. * @returns the human readable reflection probe info
  55578. */
  55579. toString(fullDetails?: boolean): string;
  55580. /**
  55581. * Get the class name of the relfection probe.
  55582. * @returns "ReflectionProbe"
  55583. */
  55584. getClassName(): string;
  55585. /**
  55586. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55587. * @returns The JSON representation of the texture
  55588. */
  55589. serialize(): any;
  55590. /**
  55591. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55592. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55593. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55594. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55595. * @returns The parsed reflection probe if successful
  55596. */
  55597. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55598. }
  55599. }
  55600. declare module BABYLON {
  55601. /** @hidden */
  55602. export var _BabylonLoaderRegistered: boolean;
  55603. /**
  55604. * Helps setting up some configuration for the babylon file loader.
  55605. */
  55606. export class BabylonFileLoaderConfiguration {
  55607. /**
  55608. * The loader does not allow injecting custom physix engine into the plugins.
  55609. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55610. * So you could set this variable to your engine import to make it work.
  55611. */
  55612. static LoaderInjectedPhysicsEngine: any;
  55613. }
  55614. }
  55615. declare module BABYLON {
  55616. /**
  55617. * The Physically based simple base material of BJS.
  55618. *
  55619. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55620. * It is used as the base class for both the specGloss and metalRough conventions.
  55621. */
  55622. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55623. /**
  55624. * Number of Simultaneous lights allowed on the material.
  55625. */
  55626. maxSimultaneousLights: number;
  55627. /**
  55628. * If sets to true, disables all the lights affecting the material.
  55629. */
  55630. disableLighting: boolean;
  55631. /**
  55632. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55633. */
  55634. environmentTexture: BaseTexture;
  55635. /**
  55636. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55637. */
  55638. invertNormalMapX: boolean;
  55639. /**
  55640. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55641. */
  55642. invertNormalMapY: boolean;
  55643. /**
  55644. * Normal map used in the model.
  55645. */
  55646. normalTexture: BaseTexture;
  55647. /**
  55648. * Emissivie color used to self-illuminate the model.
  55649. */
  55650. emissiveColor: Color3;
  55651. /**
  55652. * Emissivie texture used to self-illuminate the model.
  55653. */
  55654. emissiveTexture: BaseTexture;
  55655. /**
  55656. * Occlusion Channel Strenght.
  55657. */
  55658. occlusionStrength: number;
  55659. /**
  55660. * Occlusion Texture of the material (adding extra occlusion effects).
  55661. */
  55662. occlusionTexture: BaseTexture;
  55663. /**
  55664. * Defines the alpha limits in alpha test mode.
  55665. */
  55666. alphaCutOff: number;
  55667. /**
  55668. * Gets the current double sided mode.
  55669. */
  55670. get doubleSided(): boolean;
  55671. /**
  55672. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55673. */
  55674. set doubleSided(value: boolean);
  55675. /**
  55676. * Stores the pre-calculated light information of a mesh in a texture.
  55677. */
  55678. lightmapTexture: BaseTexture;
  55679. /**
  55680. * If true, the light map contains occlusion information instead of lighting info.
  55681. */
  55682. useLightmapAsShadowmap: boolean;
  55683. /**
  55684. * Instantiates a new PBRMaterial instance.
  55685. *
  55686. * @param name The material name
  55687. * @param scene The scene the material will be use in.
  55688. */
  55689. constructor(name: string, scene: Scene);
  55690. getClassName(): string;
  55691. }
  55692. }
  55693. declare module BABYLON {
  55694. /**
  55695. * The PBR material of BJS following the metal roughness convention.
  55696. *
  55697. * This fits to the PBR convention in the GLTF definition:
  55698. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55699. */
  55700. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55701. /**
  55702. * The base color has two different interpretations depending on the value of metalness.
  55703. * When the material is a metal, the base color is the specific measured reflectance value
  55704. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55705. * of the material.
  55706. */
  55707. baseColor: Color3;
  55708. /**
  55709. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55710. * well as opacity information in the alpha channel.
  55711. */
  55712. baseTexture: BaseTexture;
  55713. /**
  55714. * Specifies the metallic scalar value of the material.
  55715. * Can also be used to scale the metalness values of the metallic texture.
  55716. */
  55717. metallic: number;
  55718. /**
  55719. * Specifies the roughness scalar value of the material.
  55720. * Can also be used to scale the roughness values of the metallic texture.
  55721. */
  55722. roughness: number;
  55723. /**
  55724. * Texture containing both the metallic value in the B channel and the
  55725. * roughness value in the G channel to keep better precision.
  55726. */
  55727. metallicRoughnessTexture: BaseTexture;
  55728. /**
  55729. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55730. *
  55731. * @param name The material name
  55732. * @param scene The scene the material will be use in.
  55733. */
  55734. constructor(name: string, scene: Scene);
  55735. /**
  55736. * Return the currrent class name of the material.
  55737. */
  55738. getClassName(): string;
  55739. /**
  55740. * Makes a duplicate of the current material.
  55741. * @param name - name to use for the new material.
  55742. */
  55743. clone(name: string): PBRMetallicRoughnessMaterial;
  55744. /**
  55745. * Serialize the material to a parsable JSON object.
  55746. */
  55747. serialize(): any;
  55748. /**
  55749. * Parses a JSON object correponding to the serialize function.
  55750. */
  55751. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55752. }
  55753. }
  55754. declare module BABYLON {
  55755. /**
  55756. * The PBR material of BJS following the specular glossiness convention.
  55757. *
  55758. * This fits to the PBR convention in the GLTF definition:
  55759. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55760. */
  55761. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55762. /**
  55763. * Specifies the diffuse color of the material.
  55764. */
  55765. diffuseColor: Color3;
  55766. /**
  55767. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55768. * channel.
  55769. */
  55770. diffuseTexture: BaseTexture;
  55771. /**
  55772. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55773. */
  55774. specularColor: Color3;
  55775. /**
  55776. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55777. */
  55778. glossiness: number;
  55779. /**
  55780. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55781. */
  55782. specularGlossinessTexture: BaseTexture;
  55783. /**
  55784. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55785. *
  55786. * @param name The material name
  55787. * @param scene The scene the material will be use in.
  55788. */
  55789. constructor(name: string, scene: Scene);
  55790. /**
  55791. * Return the currrent class name of the material.
  55792. */
  55793. getClassName(): string;
  55794. /**
  55795. * Makes a duplicate of the current material.
  55796. * @param name - name to use for the new material.
  55797. */
  55798. clone(name: string): PBRSpecularGlossinessMaterial;
  55799. /**
  55800. * Serialize the material to a parsable JSON object.
  55801. */
  55802. serialize(): any;
  55803. /**
  55804. * Parses a JSON object correponding to the serialize function.
  55805. */
  55806. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55807. }
  55808. }
  55809. declare module BABYLON {
  55810. /**
  55811. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55812. * It can help converting any input color in a desired output one. This can then be used to create effects
  55813. * from sepia, black and white to sixties or futuristic rendering...
  55814. *
  55815. * The only supported format is currently 3dl.
  55816. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55817. */
  55818. export class ColorGradingTexture extends BaseTexture {
  55819. /**
  55820. * The current texture matrix. (will always be identity in color grading texture)
  55821. */
  55822. private _textureMatrix;
  55823. /**
  55824. * The texture URL.
  55825. */
  55826. url: string;
  55827. /**
  55828. * Empty line regex stored for GC.
  55829. */
  55830. private static _noneEmptyLineRegex;
  55831. private _engine;
  55832. /**
  55833. * Instantiates a ColorGradingTexture from the following parameters.
  55834. *
  55835. * @param url The location of the color gradind data (currently only supporting 3dl)
  55836. * @param scene The scene the texture will be used in
  55837. */
  55838. constructor(url: string, scene: Scene);
  55839. /**
  55840. * Returns the texture matrix used in most of the material.
  55841. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55842. */
  55843. getTextureMatrix(): Matrix;
  55844. /**
  55845. * Occurs when the file being loaded is a .3dl LUT file.
  55846. */
  55847. private load3dlTexture;
  55848. /**
  55849. * Starts the loading process of the texture.
  55850. */
  55851. private loadTexture;
  55852. /**
  55853. * Clones the color gradind texture.
  55854. */
  55855. clone(): ColorGradingTexture;
  55856. /**
  55857. * Called during delayed load for textures.
  55858. */
  55859. delayLoad(): void;
  55860. /**
  55861. * Parses a color grading texture serialized by Babylon.
  55862. * @param parsedTexture The texture information being parsedTexture
  55863. * @param scene The scene to load the texture in
  55864. * @param rootUrl The root url of the data assets to load
  55865. * @return A color gradind texture
  55866. */
  55867. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55868. /**
  55869. * Serializes the LUT texture to json format.
  55870. */
  55871. serialize(): any;
  55872. }
  55873. }
  55874. declare module BABYLON {
  55875. /**
  55876. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55877. */
  55878. export class EquiRectangularCubeTexture extends BaseTexture {
  55879. /** The six faces of the cube. */
  55880. private static _FacesMapping;
  55881. private _noMipmap;
  55882. private _onLoad;
  55883. private _onError;
  55884. /** The size of the cubemap. */
  55885. private _size;
  55886. /** The buffer of the image. */
  55887. private _buffer;
  55888. /** The width of the input image. */
  55889. private _width;
  55890. /** The height of the input image. */
  55891. private _height;
  55892. /** The URL to the image. */
  55893. url: string;
  55894. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55895. coordinatesMode: number;
  55896. /**
  55897. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55898. * @param url The location of the image
  55899. * @param scene The scene the texture will be used in
  55900. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55901. * @param noMipmap Forces to not generate the mipmap if true
  55902. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55903. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55904. * @param onLoad — defines a callback called when texture is loaded
  55905. * @param onError — defines a callback called if there is an error
  55906. */
  55907. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55908. /**
  55909. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55910. */
  55911. private loadImage;
  55912. /**
  55913. * Convert the image buffer into a cubemap and create a CubeTexture.
  55914. */
  55915. private loadTexture;
  55916. /**
  55917. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55918. * @param buffer The ArrayBuffer that should be converted.
  55919. * @returns The buffer as Float32Array.
  55920. */
  55921. private getFloat32ArrayFromArrayBuffer;
  55922. /**
  55923. * Get the current class name of the texture useful for serialization or dynamic coding.
  55924. * @returns "EquiRectangularCubeTexture"
  55925. */
  55926. getClassName(): string;
  55927. /**
  55928. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55929. * @returns A clone of the current EquiRectangularCubeTexture.
  55930. */
  55931. clone(): EquiRectangularCubeTexture;
  55932. }
  55933. }
  55934. declare module BABYLON {
  55935. /**
  55936. * Based on jsTGALoader - Javascript loader for TGA file
  55937. * By Vincent Thibault
  55938. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55939. */
  55940. export class TGATools {
  55941. private static _TYPE_INDEXED;
  55942. private static _TYPE_RGB;
  55943. private static _TYPE_GREY;
  55944. private static _TYPE_RLE_INDEXED;
  55945. private static _TYPE_RLE_RGB;
  55946. private static _TYPE_RLE_GREY;
  55947. private static _ORIGIN_MASK;
  55948. private static _ORIGIN_SHIFT;
  55949. private static _ORIGIN_BL;
  55950. private static _ORIGIN_BR;
  55951. private static _ORIGIN_UL;
  55952. private static _ORIGIN_UR;
  55953. /**
  55954. * Gets the header of a TGA file
  55955. * @param data defines the TGA data
  55956. * @returns the header
  55957. */
  55958. static GetTGAHeader(data: Uint8Array): any;
  55959. /**
  55960. * Uploads TGA content to a Babylon Texture
  55961. * @hidden
  55962. */
  55963. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55964. /** @hidden */
  55965. 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;
  55966. /** @hidden */
  55967. 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;
  55968. /** @hidden */
  55969. 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;
  55970. /** @hidden */
  55971. 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;
  55972. /** @hidden */
  55973. 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;
  55974. /** @hidden */
  55975. 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;
  55976. }
  55977. }
  55978. declare module BABYLON {
  55979. /**
  55980. * Implementation of the TGA Texture Loader.
  55981. * @hidden
  55982. */
  55983. export class _TGATextureLoader implements IInternalTextureLoader {
  55984. /**
  55985. * Defines wether the loader supports cascade loading the different faces.
  55986. */
  55987. readonly supportCascades: boolean;
  55988. /**
  55989. * This returns if the loader support the current file information.
  55990. * @param extension defines the file extension of the file being loaded
  55991. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55992. * @param fallback defines the fallback internal texture if any
  55993. * @param isBase64 defines whether the texture is encoded as a base64
  55994. * @param isBuffer defines whether the texture data are stored as a buffer
  55995. * @returns true if the loader can load the specified file
  55996. */
  55997. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55998. /**
  55999. * Transform the url before loading if required.
  56000. * @param rootUrl the url of the texture
  56001. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56002. * @returns the transformed texture
  56003. */
  56004. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56005. /**
  56006. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56007. * @param rootUrl the url of the texture
  56008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56009. * @returns the fallback texture
  56010. */
  56011. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56012. /**
  56013. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56014. * @param data contains the texture data
  56015. * @param texture defines the BabylonJS internal texture
  56016. * @param createPolynomials will be true if polynomials have been requested
  56017. * @param onLoad defines the callback to trigger once the texture is ready
  56018. * @param onError defines the callback to trigger in case of error
  56019. */
  56020. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56021. /**
  56022. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56023. * @param data contains the texture data
  56024. * @param texture defines the BabylonJS internal texture
  56025. * @param callback defines the method to call once ready to upload
  56026. */
  56027. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56028. }
  56029. }
  56030. declare module BABYLON {
  56031. /**
  56032. * Info about the .basis files
  56033. */
  56034. class BasisFileInfo {
  56035. /**
  56036. * If the file has alpha
  56037. */
  56038. hasAlpha: boolean;
  56039. /**
  56040. * Info about each image of the basis file
  56041. */
  56042. images: Array<{
  56043. levels: Array<{
  56044. width: number;
  56045. height: number;
  56046. transcodedPixels: ArrayBufferView;
  56047. }>;
  56048. }>;
  56049. }
  56050. /**
  56051. * Result of transcoding a basis file
  56052. */
  56053. class TranscodeResult {
  56054. /**
  56055. * Info about the .basis file
  56056. */
  56057. fileInfo: BasisFileInfo;
  56058. /**
  56059. * Format to use when loading the file
  56060. */
  56061. format: number;
  56062. }
  56063. /**
  56064. * Configuration options for the Basis transcoder
  56065. */
  56066. export class BasisTranscodeConfiguration {
  56067. /**
  56068. * Supported compression formats used to determine the supported output format of the transcoder
  56069. */
  56070. supportedCompressionFormats?: {
  56071. /**
  56072. * etc1 compression format
  56073. */
  56074. etc1?: boolean;
  56075. /**
  56076. * s3tc compression format
  56077. */
  56078. s3tc?: boolean;
  56079. /**
  56080. * pvrtc compression format
  56081. */
  56082. pvrtc?: boolean;
  56083. /**
  56084. * etc2 compression format
  56085. */
  56086. etc2?: boolean;
  56087. };
  56088. /**
  56089. * If mipmap levels should be loaded for transcoded images (Default: true)
  56090. */
  56091. loadMipmapLevels?: boolean;
  56092. /**
  56093. * Index of a single image to load (Default: all images)
  56094. */
  56095. loadSingleImage?: number;
  56096. }
  56097. /**
  56098. * Used to load .Basis files
  56099. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56100. */
  56101. export class BasisTools {
  56102. private static _IgnoreSupportedFormats;
  56103. /**
  56104. * URL to use when loading the basis transcoder
  56105. */
  56106. static JSModuleURL: string;
  56107. /**
  56108. * URL to use when loading the wasm module for the transcoder
  56109. */
  56110. static WasmModuleURL: string;
  56111. /**
  56112. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56113. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56114. * @returns internal format corresponding to the Basis format
  56115. */
  56116. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56117. private static _WorkerPromise;
  56118. private static _Worker;
  56119. private static _actionId;
  56120. private static _CreateWorkerAsync;
  56121. /**
  56122. * Transcodes a loaded image file to compressed pixel data
  56123. * @param data image data to transcode
  56124. * @param config configuration options for the transcoding
  56125. * @returns a promise resulting in the transcoded image
  56126. */
  56127. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56128. /**
  56129. * Loads a texture from the transcode result
  56130. * @param texture texture load to
  56131. * @param transcodeResult the result of transcoding the basis file to load from
  56132. */
  56133. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56134. }
  56135. }
  56136. declare module BABYLON {
  56137. /**
  56138. * Loader for .basis file format
  56139. */
  56140. export class _BasisTextureLoader implements IInternalTextureLoader {
  56141. /**
  56142. * Defines whether the loader supports cascade loading the different faces.
  56143. */
  56144. readonly supportCascades: boolean;
  56145. /**
  56146. * This returns if the loader support the current file information.
  56147. * @param extension defines the file extension of the file being loaded
  56148. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56149. * @param fallback defines the fallback internal texture if any
  56150. * @param isBase64 defines whether the texture is encoded as a base64
  56151. * @param isBuffer defines whether the texture data are stored as a buffer
  56152. * @returns true if the loader can load the specified file
  56153. */
  56154. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56155. /**
  56156. * Transform the url before loading if required.
  56157. * @param rootUrl the url of the texture
  56158. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56159. * @returns the transformed texture
  56160. */
  56161. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56162. /**
  56163. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56164. * @param rootUrl the url of the texture
  56165. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56166. * @returns the fallback texture
  56167. */
  56168. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56169. /**
  56170. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56171. * @param data contains the texture data
  56172. * @param texture defines the BabylonJS internal texture
  56173. * @param createPolynomials will be true if polynomials have been requested
  56174. * @param onLoad defines the callback to trigger once the texture is ready
  56175. * @param onError defines the callback to trigger in case of error
  56176. */
  56177. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56178. /**
  56179. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56180. * @param data contains the texture data
  56181. * @param texture defines the BabylonJS internal texture
  56182. * @param callback defines the method to call once ready to upload
  56183. */
  56184. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56185. }
  56186. }
  56187. declare module BABYLON {
  56188. /**
  56189. * 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.
  56190. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56191. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56192. */
  56193. export class CustomProceduralTexture extends ProceduralTexture {
  56194. private _animate;
  56195. private _time;
  56196. private _config;
  56197. private _texturePath;
  56198. /**
  56199. * Instantiates a new Custom Procedural Texture.
  56200. * 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.
  56201. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56202. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56203. * @param name Define the name of the texture
  56204. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56205. * @param size Define the size of the texture to create
  56206. * @param scene Define the scene the texture belongs to
  56207. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56208. * @param generateMipMaps Define if the texture should creates mip maps or not
  56209. */
  56210. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56211. private _loadJson;
  56212. /**
  56213. * Is the texture ready to be used ? (rendered at least once)
  56214. * @returns true if ready, otherwise, false.
  56215. */
  56216. isReady(): boolean;
  56217. /**
  56218. * Render the texture to its associated render target.
  56219. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56220. */
  56221. render(useCameraPostProcess?: boolean): void;
  56222. /**
  56223. * Update the list of dependant textures samplers in the shader.
  56224. */
  56225. updateTextures(): void;
  56226. /**
  56227. * Update the uniform values of the procedural texture in the shader.
  56228. */
  56229. updateShaderUniforms(): void;
  56230. /**
  56231. * Define if the texture animates or not.
  56232. */
  56233. get animate(): boolean;
  56234. set animate(value: boolean);
  56235. }
  56236. }
  56237. declare module BABYLON {
  56238. /** @hidden */
  56239. export var noisePixelShader: {
  56240. name: string;
  56241. shader: string;
  56242. };
  56243. }
  56244. declare module BABYLON {
  56245. /**
  56246. * Class used to generate noise procedural textures
  56247. */
  56248. export class NoiseProceduralTexture extends ProceduralTexture {
  56249. private _time;
  56250. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56251. brightness: number;
  56252. /** Defines the number of octaves to process */
  56253. octaves: number;
  56254. /** Defines the level of persistence (0.8 by default) */
  56255. persistence: number;
  56256. /** Gets or sets animation speed factor (default is 1) */
  56257. animationSpeedFactor: number;
  56258. /**
  56259. * Creates a new NoiseProceduralTexture
  56260. * @param name defines the name fo the texture
  56261. * @param size defines the size of the texture (default is 256)
  56262. * @param scene defines the hosting scene
  56263. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56264. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56265. */
  56266. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56267. private _updateShaderUniforms;
  56268. protected _getDefines(): string;
  56269. /** Generate the current state of the procedural texture */
  56270. render(useCameraPostProcess?: boolean): void;
  56271. /**
  56272. * Serializes this noise procedural texture
  56273. * @returns a serialized noise procedural texture object
  56274. */
  56275. serialize(): any;
  56276. /**
  56277. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56278. * @param parsedTexture defines parsed texture data
  56279. * @param scene defines the current scene
  56280. * @param rootUrl defines the root URL containing noise procedural texture information
  56281. * @returns a parsed NoiseProceduralTexture
  56282. */
  56283. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56284. }
  56285. }
  56286. declare module BABYLON {
  56287. /**
  56288. * Raw cube texture where the raw buffers are passed in
  56289. */
  56290. export class RawCubeTexture extends CubeTexture {
  56291. /**
  56292. * Creates a cube texture where the raw buffers are passed in.
  56293. * @param scene defines the scene the texture is attached to
  56294. * @param data defines the array of data to use to create each face
  56295. * @param size defines the size of the textures
  56296. * @param format defines the format of the data
  56297. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56298. * @param generateMipMaps defines if the engine should generate the mip levels
  56299. * @param invertY defines if data must be stored with Y axis inverted
  56300. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56301. * @param compression defines the compression used (null by default)
  56302. */
  56303. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56304. /**
  56305. * Updates the raw cube texture.
  56306. * @param data defines the data to store
  56307. * @param format defines the data format
  56308. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56309. * @param invertY defines if data must be stored with Y axis inverted
  56310. * @param compression defines the compression used (null by default)
  56311. * @param level defines which level of the texture to update
  56312. */
  56313. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56314. /**
  56315. * Updates a raw cube texture with RGBD encoded data.
  56316. * @param data defines the array of data [mipmap][face] to use to create each face
  56317. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56318. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56319. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56320. * @returns a promsie that resolves when the operation is complete
  56321. */
  56322. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56323. /**
  56324. * Clones the raw cube texture.
  56325. * @return a new cube texture
  56326. */
  56327. clone(): CubeTexture;
  56328. /** @hidden */
  56329. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56330. }
  56331. }
  56332. declare module BABYLON {
  56333. /**
  56334. * Class used to store 3D textures containing user data
  56335. */
  56336. export class RawTexture3D extends Texture {
  56337. /** Gets or sets the texture format to use */
  56338. format: number;
  56339. private _engine;
  56340. /**
  56341. * Create a new RawTexture3D
  56342. * @param data defines the data of the texture
  56343. * @param width defines the width of the texture
  56344. * @param height defines the height of the texture
  56345. * @param depth defines the depth of the texture
  56346. * @param format defines the texture format to use
  56347. * @param scene defines the hosting scene
  56348. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56349. * @param invertY defines if texture must be stored with Y axis inverted
  56350. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56351. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56352. */
  56353. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56354. /** Gets or sets the texture format to use */
  56355. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56356. /**
  56357. * Update the texture with new data
  56358. * @param data defines the data to store in the texture
  56359. */
  56360. update(data: ArrayBufferView): void;
  56361. }
  56362. }
  56363. declare module BABYLON {
  56364. /**
  56365. * Class used to store 2D array textures containing user data
  56366. */
  56367. export class RawTexture2DArray extends Texture {
  56368. /** Gets or sets the texture format to use */
  56369. format: number;
  56370. private _engine;
  56371. /**
  56372. * Create a new RawTexture2DArray
  56373. * @param data defines the data of the texture
  56374. * @param width defines the width of the texture
  56375. * @param height defines the height of the texture
  56376. * @param depth defines the number of layers of the texture
  56377. * @param format defines the texture format to use
  56378. * @param scene defines the hosting scene
  56379. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56380. * @param invertY defines if texture must be stored with Y axis inverted
  56381. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56382. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56383. */
  56384. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56385. /** Gets or sets the texture format to use */
  56386. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56387. /**
  56388. * Update the texture with new data
  56389. * @param data defines the data to store in the texture
  56390. */
  56391. update(data: ArrayBufferView): void;
  56392. }
  56393. }
  56394. declare module BABYLON {
  56395. /**
  56396. * Creates a refraction texture used by refraction channel of the standard material.
  56397. * It is like a mirror but to see through a material.
  56398. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56399. */
  56400. export class RefractionTexture extends RenderTargetTexture {
  56401. /**
  56402. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56403. * 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.
  56404. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56405. */
  56406. refractionPlane: Plane;
  56407. /**
  56408. * Define how deep under the surface we should see.
  56409. */
  56410. depth: number;
  56411. /**
  56412. * Creates a refraction texture used by refraction channel of the standard material.
  56413. * It is like a mirror but to see through a material.
  56414. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56415. * @param name Define the texture name
  56416. * @param size Define the size of the underlying texture
  56417. * @param scene Define the scene the refraction belongs to
  56418. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56419. */
  56420. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56421. /**
  56422. * Clone the refraction texture.
  56423. * @returns the cloned texture
  56424. */
  56425. clone(): RefractionTexture;
  56426. /**
  56427. * Serialize the texture to a JSON representation you could use in Parse later on
  56428. * @returns the serialized JSON representation
  56429. */
  56430. serialize(): any;
  56431. }
  56432. }
  56433. declare module BABYLON {
  56434. /**
  56435. * Defines the options related to the creation of an HtmlElementTexture
  56436. */
  56437. export interface IHtmlElementTextureOptions {
  56438. /**
  56439. * Defines wether mip maps should be created or not.
  56440. */
  56441. generateMipMaps?: boolean;
  56442. /**
  56443. * Defines the sampling mode of the texture.
  56444. */
  56445. samplingMode?: number;
  56446. /**
  56447. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56448. */
  56449. engine: Nullable<ThinEngine>;
  56450. /**
  56451. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56452. */
  56453. scene: Nullable<Scene>;
  56454. }
  56455. /**
  56456. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56457. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56458. * is automatically managed.
  56459. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56460. * in your application.
  56461. *
  56462. * As the update is not automatic, you need to call them manually.
  56463. */
  56464. export class HtmlElementTexture extends BaseTexture {
  56465. /**
  56466. * The texture URL.
  56467. */
  56468. element: HTMLVideoElement | HTMLCanvasElement;
  56469. private static readonly DefaultOptions;
  56470. private _textureMatrix;
  56471. private _engine;
  56472. private _isVideo;
  56473. private _generateMipMaps;
  56474. private _samplingMode;
  56475. /**
  56476. * Instantiates a HtmlElementTexture from the following parameters.
  56477. *
  56478. * @param name Defines the name of the texture
  56479. * @param element Defines the video or canvas the texture is filled with
  56480. * @param options Defines the other none mandatory texture creation options
  56481. */
  56482. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56483. private _createInternalTexture;
  56484. /**
  56485. * Returns the texture matrix used in most of the material.
  56486. */
  56487. getTextureMatrix(): Matrix;
  56488. /**
  56489. * Updates the content of the texture.
  56490. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56491. */
  56492. update(invertY?: Nullable<boolean>): void;
  56493. }
  56494. }
  56495. declare module BABYLON {
  56496. /**
  56497. * Defines the basic options interface of a TexturePacker Frame
  56498. */
  56499. export interface ITexturePackerFrame {
  56500. /**
  56501. * The frame ID
  56502. */
  56503. id: number;
  56504. /**
  56505. * The frames Scale
  56506. */
  56507. scale: Vector2;
  56508. /**
  56509. * The Frames offset
  56510. */
  56511. offset: Vector2;
  56512. }
  56513. /**
  56514. * This is a support class for frame Data on texture packer sets.
  56515. */
  56516. export class TexturePackerFrame implements ITexturePackerFrame {
  56517. /**
  56518. * The frame ID
  56519. */
  56520. id: number;
  56521. /**
  56522. * The frames Scale
  56523. */
  56524. scale: Vector2;
  56525. /**
  56526. * The Frames offset
  56527. */
  56528. offset: Vector2;
  56529. /**
  56530. * Initializes a texture package frame.
  56531. * @param id The numerical frame identifier
  56532. * @param scale Scalar Vector2 for UV frame
  56533. * @param offset Vector2 for the frame position in UV units.
  56534. * @returns TexturePackerFrame
  56535. */
  56536. constructor(id: number, scale: Vector2, offset: Vector2);
  56537. }
  56538. }
  56539. declare module BABYLON {
  56540. /**
  56541. * Defines the basic options interface of a TexturePacker
  56542. */
  56543. export interface ITexturePackerOptions {
  56544. /**
  56545. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56546. */
  56547. map?: string[];
  56548. /**
  56549. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56550. */
  56551. uvsIn?: string;
  56552. /**
  56553. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56554. */
  56555. uvsOut?: string;
  56556. /**
  56557. * number representing the layout style. Defaults to LAYOUT_STRIP
  56558. */
  56559. layout?: number;
  56560. /**
  56561. * number of columns if using custom column count layout(2). This defaults to 4.
  56562. */
  56563. colnum?: number;
  56564. /**
  56565. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56566. */
  56567. updateInputMeshes?: boolean;
  56568. /**
  56569. * boolean flag to dispose all the source textures. Defaults to true.
  56570. */
  56571. disposeSources?: boolean;
  56572. /**
  56573. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56574. */
  56575. fillBlanks?: boolean;
  56576. /**
  56577. * string value representing the context fill style color. Defaults to 'black'.
  56578. */
  56579. customFillColor?: string;
  56580. /**
  56581. * Width and Height Value of each Frame in the TexturePacker Sets
  56582. */
  56583. frameSize?: number;
  56584. /**
  56585. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56586. */
  56587. paddingRatio?: number;
  56588. /**
  56589. * Number that declares the fill method for the padding gutter.
  56590. */
  56591. paddingMode?: number;
  56592. /**
  56593. * If in SUBUV_COLOR padding mode what color to use.
  56594. */
  56595. paddingColor?: Color3 | Color4;
  56596. }
  56597. /**
  56598. * Defines the basic interface of a TexturePacker JSON File
  56599. */
  56600. export interface ITexturePackerJSON {
  56601. /**
  56602. * The frame ID
  56603. */
  56604. name: string;
  56605. /**
  56606. * The base64 channel data
  56607. */
  56608. sets: any;
  56609. /**
  56610. * The options of the Packer
  56611. */
  56612. options: ITexturePackerOptions;
  56613. /**
  56614. * The frame data of the Packer
  56615. */
  56616. frames: Array<number>;
  56617. }
  56618. /**
  56619. * This is a support class that generates a series of packed texture sets.
  56620. * @see https://doc.babylonjs.com/babylon101/materials
  56621. */
  56622. export class TexturePacker {
  56623. /** Packer Layout Constant 0 */
  56624. static readonly LAYOUT_STRIP: number;
  56625. /** Packer Layout Constant 1 */
  56626. static readonly LAYOUT_POWER2: number;
  56627. /** Packer Layout Constant 2 */
  56628. static readonly LAYOUT_COLNUM: number;
  56629. /** Packer Layout Constant 0 */
  56630. static readonly SUBUV_WRAP: number;
  56631. /** Packer Layout Constant 1 */
  56632. static readonly SUBUV_EXTEND: number;
  56633. /** Packer Layout Constant 2 */
  56634. static readonly SUBUV_COLOR: number;
  56635. /** The Name of the Texture Package */
  56636. name: string;
  56637. /** The scene scope of the TexturePacker */
  56638. scene: Scene;
  56639. /** The Meshes to target */
  56640. meshes: AbstractMesh[];
  56641. /** Arguments passed with the Constructor */
  56642. options: ITexturePackerOptions;
  56643. /** The promise that is started upon initialization */
  56644. promise: Nullable<Promise<TexturePacker | string>>;
  56645. /** The Container object for the channel sets that are generated */
  56646. sets: object;
  56647. /** The Container array for the frames that are generated */
  56648. frames: TexturePackerFrame[];
  56649. /** The expected number of textures the system is parsing. */
  56650. private _expecting;
  56651. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56652. private _paddingValue;
  56653. /**
  56654. * Initializes a texture package series from an array of meshes or a single mesh.
  56655. * @param name The name of the package
  56656. * @param meshes The target meshes to compose the package from
  56657. * @param options The arguments that texture packer should follow while building.
  56658. * @param scene The scene which the textures are scoped to.
  56659. * @returns TexturePacker
  56660. */
  56661. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56662. /**
  56663. * Starts the package process
  56664. * @param resolve The promises resolution function
  56665. * @returns TexturePacker
  56666. */
  56667. private _createFrames;
  56668. /**
  56669. * Calculates the Size of the Channel Sets
  56670. * @returns Vector2
  56671. */
  56672. private _calculateSize;
  56673. /**
  56674. * Calculates the UV data for the frames.
  56675. * @param baseSize the base frameSize
  56676. * @param padding the base frame padding
  56677. * @param dtSize size of the Dynamic Texture for that channel
  56678. * @param dtUnits is 1/dtSize
  56679. * @param update flag to update the input meshes
  56680. */
  56681. private _calculateMeshUVFrames;
  56682. /**
  56683. * Calculates the frames Offset.
  56684. * @param index of the frame
  56685. * @returns Vector2
  56686. */
  56687. private _getFrameOffset;
  56688. /**
  56689. * Updates a Mesh to the frame data
  56690. * @param mesh that is the target
  56691. * @param frameID or the frame index
  56692. */
  56693. private _updateMeshUV;
  56694. /**
  56695. * Updates a Meshes materials to use the texture packer channels
  56696. * @param m is the mesh to target
  56697. * @param force all channels on the packer to be set.
  56698. */
  56699. private _updateTextureReferences;
  56700. /**
  56701. * Public method to set a Mesh to a frame
  56702. * @param m that is the target
  56703. * @param frameID or the frame index
  56704. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56705. */
  56706. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56707. /**
  56708. * Starts the async promise to compile the texture packer.
  56709. * @returns Promise<void>
  56710. */
  56711. processAsync(): Promise<void>;
  56712. /**
  56713. * Disposes all textures associated with this packer
  56714. */
  56715. dispose(): void;
  56716. /**
  56717. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56718. * @param imageType is the image type to use.
  56719. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56720. */
  56721. download(imageType?: string, quality?: number): void;
  56722. /**
  56723. * Public method to load a texturePacker JSON file.
  56724. * @param data of the JSON file in string format.
  56725. */
  56726. updateFromJSON(data: string): void;
  56727. }
  56728. }
  56729. declare module BABYLON {
  56730. /**
  56731. * Enum used to define the target of a block
  56732. */
  56733. export enum NodeMaterialBlockTargets {
  56734. /** Vertex shader */
  56735. Vertex = 1,
  56736. /** Fragment shader */
  56737. Fragment = 2,
  56738. /** Neutral */
  56739. Neutral = 4,
  56740. /** Vertex and Fragment */
  56741. VertexAndFragment = 3
  56742. }
  56743. }
  56744. declare module BABYLON {
  56745. /**
  56746. * Defines the kind of connection point for node based material
  56747. */
  56748. export enum NodeMaterialBlockConnectionPointTypes {
  56749. /** Float */
  56750. Float = 1,
  56751. /** Int */
  56752. Int = 2,
  56753. /** Vector2 */
  56754. Vector2 = 4,
  56755. /** Vector3 */
  56756. Vector3 = 8,
  56757. /** Vector4 */
  56758. Vector4 = 16,
  56759. /** Color3 */
  56760. Color3 = 32,
  56761. /** Color4 */
  56762. Color4 = 64,
  56763. /** Matrix */
  56764. Matrix = 128,
  56765. /** Detect type based on connection */
  56766. AutoDetect = 1024,
  56767. /** Output type that will be defined by input type */
  56768. BasedOnInput = 2048
  56769. }
  56770. }
  56771. declare module BABYLON {
  56772. /**
  56773. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56774. */
  56775. export enum NodeMaterialBlockConnectionPointMode {
  56776. /** Value is an uniform */
  56777. Uniform = 0,
  56778. /** Value is a mesh attribute */
  56779. Attribute = 1,
  56780. /** Value is a varying between vertex and fragment shaders */
  56781. Varying = 2,
  56782. /** Mode is undefined */
  56783. Undefined = 3
  56784. }
  56785. }
  56786. declare module BABYLON {
  56787. /**
  56788. * Enum used to define system values e.g. values automatically provided by the system
  56789. */
  56790. export enum NodeMaterialSystemValues {
  56791. /** World */
  56792. World = 1,
  56793. /** View */
  56794. View = 2,
  56795. /** Projection */
  56796. Projection = 3,
  56797. /** ViewProjection */
  56798. ViewProjection = 4,
  56799. /** WorldView */
  56800. WorldView = 5,
  56801. /** WorldViewProjection */
  56802. WorldViewProjection = 6,
  56803. /** CameraPosition */
  56804. CameraPosition = 7,
  56805. /** Fog Color */
  56806. FogColor = 8,
  56807. /** Delta time */
  56808. DeltaTime = 9
  56809. }
  56810. }
  56811. declare module BABYLON {
  56812. /**
  56813. * Root class for all node material optimizers
  56814. */
  56815. export class NodeMaterialOptimizer {
  56816. /**
  56817. * Function used to optimize a NodeMaterial graph
  56818. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56819. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56820. */
  56821. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56822. }
  56823. }
  56824. declare module BABYLON {
  56825. /**
  56826. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56827. */
  56828. export class TransformBlock extends NodeMaterialBlock {
  56829. /**
  56830. * Defines the value to use to complement W value to transform it to a Vector4
  56831. */
  56832. complementW: number;
  56833. /**
  56834. * Defines the value to use to complement z value to transform it to a Vector4
  56835. */
  56836. complementZ: number;
  56837. /**
  56838. * Creates a new TransformBlock
  56839. * @param name defines the block name
  56840. */
  56841. constructor(name: string);
  56842. /**
  56843. * Gets the current class name
  56844. * @returns the class name
  56845. */
  56846. getClassName(): string;
  56847. /**
  56848. * Gets the vector input
  56849. */
  56850. get vector(): NodeMaterialConnectionPoint;
  56851. /**
  56852. * Gets the output component
  56853. */
  56854. get output(): NodeMaterialConnectionPoint;
  56855. /**
  56856. * Gets the matrix transform input
  56857. */
  56858. get transform(): NodeMaterialConnectionPoint;
  56859. protected _buildBlock(state: NodeMaterialBuildState): this;
  56860. serialize(): any;
  56861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56862. protected _dumpPropertiesCode(): string;
  56863. }
  56864. }
  56865. declare module BABYLON {
  56866. /**
  56867. * Block used to output the vertex position
  56868. */
  56869. export class VertexOutputBlock extends NodeMaterialBlock {
  56870. /**
  56871. * Creates a new VertexOutputBlock
  56872. * @param name defines the block name
  56873. */
  56874. constructor(name: string);
  56875. /**
  56876. * Gets the current class name
  56877. * @returns the class name
  56878. */
  56879. getClassName(): string;
  56880. /**
  56881. * Gets the vector input component
  56882. */
  56883. get vector(): NodeMaterialConnectionPoint;
  56884. protected _buildBlock(state: NodeMaterialBuildState): this;
  56885. }
  56886. }
  56887. declare module BABYLON {
  56888. /**
  56889. * Block used to output the final color
  56890. */
  56891. export class FragmentOutputBlock extends NodeMaterialBlock {
  56892. /**
  56893. * Create a new FragmentOutputBlock
  56894. * @param name defines the block name
  56895. */
  56896. constructor(name: string);
  56897. /**
  56898. * Gets the current class name
  56899. * @returns the class name
  56900. */
  56901. getClassName(): string;
  56902. /**
  56903. * Gets the rgba input component
  56904. */
  56905. get rgba(): NodeMaterialConnectionPoint;
  56906. /**
  56907. * Gets the rgb input component
  56908. */
  56909. get rgb(): NodeMaterialConnectionPoint;
  56910. /**
  56911. * Gets the a input component
  56912. */
  56913. get a(): NodeMaterialConnectionPoint;
  56914. protected _buildBlock(state: NodeMaterialBuildState): this;
  56915. }
  56916. }
  56917. declare module BABYLON {
  56918. /**
  56919. * Block used to read a reflection texture from a sampler
  56920. */
  56921. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56922. private _define3DName;
  56923. private _defineCubicName;
  56924. private _defineExplicitName;
  56925. private _defineProjectionName;
  56926. private _defineLocalCubicName;
  56927. private _defineSphericalName;
  56928. private _definePlanarName;
  56929. private _defineEquirectangularName;
  56930. private _defineMirroredEquirectangularFixedName;
  56931. private _defineEquirectangularFixedName;
  56932. private _defineSkyboxName;
  56933. private _cubeSamplerName;
  56934. private _2DSamplerName;
  56935. private _positionUVWName;
  56936. private _directionWName;
  56937. private _reflectionCoordsName;
  56938. private _reflection2DCoordsName;
  56939. private _reflectionColorName;
  56940. private _reflectionMatrixName;
  56941. /**
  56942. * Gets or sets the texture associated with the node
  56943. */
  56944. texture: Nullable<BaseTexture>;
  56945. /**
  56946. * Create a new TextureBlock
  56947. * @param name defines the block name
  56948. */
  56949. constructor(name: string);
  56950. /**
  56951. * Gets the current class name
  56952. * @returns the class name
  56953. */
  56954. getClassName(): string;
  56955. /**
  56956. * Gets the world position input component
  56957. */
  56958. get position(): NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the world position input component
  56961. */
  56962. get worldPosition(): NodeMaterialConnectionPoint;
  56963. /**
  56964. * Gets the world normal input component
  56965. */
  56966. get worldNormal(): NodeMaterialConnectionPoint;
  56967. /**
  56968. * Gets the world input component
  56969. */
  56970. get world(): NodeMaterialConnectionPoint;
  56971. /**
  56972. * Gets the camera (or eye) position component
  56973. */
  56974. get cameraPosition(): NodeMaterialConnectionPoint;
  56975. /**
  56976. * Gets the view input component
  56977. */
  56978. get view(): NodeMaterialConnectionPoint;
  56979. /**
  56980. * Gets the rgb output component
  56981. */
  56982. get rgb(): NodeMaterialConnectionPoint;
  56983. /**
  56984. * Gets the r output component
  56985. */
  56986. get r(): NodeMaterialConnectionPoint;
  56987. /**
  56988. * Gets the g output component
  56989. */
  56990. get g(): NodeMaterialConnectionPoint;
  56991. /**
  56992. * Gets the b output component
  56993. */
  56994. get b(): NodeMaterialConnectionPoint;
  56995. autoConfigure(material: NodeMaterial): void;
  56996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56997. isReady(): boolean;
  56998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56999. private _injectVertexCode;
  57000. private _writeOutput;
  57001. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57002. protected _dumpPropertiesCode(): string;
  57003. serialize(): any;
  57004. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57005. }
  57006. }
  57007. declare module BABYLON {
  57008. /**
  57009. * Interface used to configure the node material editor
  57010. */
  57011. export interface INodeMaterialEditorOptions {
  57012. /** Define the URl to load node editor script */
  57013. editorURL?: string;
  57014. }
  57015. /** @hidden */
  57016. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57017. NORMAL: boolean;
  57018. TANGENT: boolean;
  57019. UV1: boolean;
  57020. /** BONES */
  57021. NUM_BONE_INFLUENCERS: number;
  57022. BonesPerMesh: number;
  57023. BONETEXTURE: boolean;
  57024. /** MORPH TARGETS */
  57025. MORPHTARGETS: boolean;
  57026. MORPHTARGETS_NORMAL: boolean;
  57027. MORPHTARGETS_TANGENT: boolean;
  57028. MORPHTARGETS_UV: boolean;
  57029. NUM_MORPH_INFLUENCERS: number;
  57030. /** IMAGE PROCESSING */
  57031. IMAGEPROCESSING: boolean;
  57032. VIGNETTE: boolean;
  57033. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57034. VIGNETTEBLENDMODEOPAQUE: boolean;
  57035. TONEMAPPING: boolean;
  57036. TONEMAPPING_ACES: boolean;
  57037. CONTRAST: boolean;
  57038. EXPOSURE: boolean;
  57039. COLORCURVES: boolean;
  57040. COLORGRADING: boolean;
  57041. COLORGRADING3D: boolean;
  57042. SAMPLER3DGREENDEPTH: boolean;
  57043. SAMPLER3DBGRMAP: boolean;
  57044. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57045. /** MISC. */
  57046. BUMPDIRECTUV: number;
  57047. constructor();
  57048. setValue(name: string, value: boolean): void;
  57049. }
  57050. /**
  57051. * Class used to configure NodeMaterial
  57052. */
  57053. export interface INodeMaterialOptions {
  57054. /**
  57055. * Defines if blocks should emit comments
  57056. */
  57057. emitComments: boolean;
  57058. }
  57059. /**
  57060. * Class used to create a node based material built by assembling shader blocks
  57061. */
  57062. export class NodeMaterial extends PushMaterial {
  57063. private static _BuildIdGenerator;
  57064. private _options;
  57065. private _vertexCompilationState;
  57066. private _fragmentCompilationState;
  57067. private _sharedData;
  57068. private _buildId;
  57069. private _buildWasSuccessful;
  57070. private _cachedWorldViewMatrix;
  57071. private _cachedWorldViewProjectionMatrix;
  57072. private _optimizers;
  57073. private _animationFrame;
  57074. /** Define the Url to load node editor script */
  57075. static EditorURL: string;
  57076. /** Define the Url to load snippets */
  57077. static SnippetUrl: string;
  57078. private BJSNODEMATERIALEDITOR;
  57079. /** Get the inspector from bundle or global */
  57080. private _getGlobalNodeMaterialEditor;
  57081. /**
  57082. * Gets or sets data used by visual editor
  57083. * @see https://nme.babylonjs.com
  57084. */
  57085. editorData: any;
  57086. /**
  57087. * 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)
  57088. */
  57089. ignoreAlpha: boolean;
  57090. /**
  57091. * Defines the maximum number of lights that can be used in the material
  57092. */
  57093. maxSimultaneousLights: number;
  57094. /**
  57095. * Observable raised when the material is built
  57096. */
  57097. onBuildObservable: Observable<NodeMaterial>;
  57098. /**
  57099. * Gets or sets the root nodes of the material vertex shader
  57100. */
  57101. _vertexOutputNodes: NodeMaterialBlock[];
  57102. /**
  57103. * Gets or sets the root nodes of the material fragment (pixel) shader
  57104. */
  57105. _fragmentOutputNodes: NodeMaterialBlock[];
  57106. /** Gets or sets options to control the node material overall behavior */
  57107. get options(): INodeMaterialOptions;
  57108. set options(options: INodeMaterialOptions);
  57109. /**
  57110. * Default configuration related to image processing available in the standard Material.
  57111. */
  57112. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57113. /**
  57114. * Gets the image processing configuration used either in this material.
  57115. */
  57116. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57117. /**
  57118. * Sets the Default image processing configuration used either in the this material.
  57119. *
  57120. * If sets to null, the scene one is in use.
  57121. */
  57122. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57123. /**
  57124. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57125. */
  57126. attachedBlocks: NodeMaterialBlock[];
  57127. /**
  57128. * Create a new node based material
  57129. * @param name defines the material name
  57130. * @param scene defines the hosting scene
  57131. * @param options defines creation option
  57132. */
  57133. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57134. /**
  57135. * Gets the current class name of the material e.g. "NodeMaterial"
  57136. * @returns the class name
  57137. */
  57138. getClassName(): string;
  57139. /**
  57140. * Keep track of the image processing observer to allow dispose and replace.
  57141. */
  57142. private _imageProcessingObserver;
  57143. /**
  57144. * Attaches a new image processing configuration to the Standard Material.
  57145. * @param configuration
  57146. */
  57147. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57148. /**
  57149. * Get a block by its name
  57150. * @param name defines the name of the block to retrieve
  57151. * @returns the required block or null if not found
  57152. */
  57153. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57154. /**
  57155. * Get a block by its name
  57156. * @param predicate defines the predicate used to find the good candidate
  57157. * @returns the required block or null if not found
  57158. */
  57159. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57160. /**
  57161. * Get an input block by its name
  57162. * @param predicate defines the predicate used to find the good candidate
  57163. * @returns the required input block or null if not found
  57164. */
  57165. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57166. /**
  57167. * Gets the list of input blocks attached to this material
  57168. * @returns an array of InputBlocks
  57169. */
  57170. getInputBlocks(): InputBlock[];
  57171. /**
  57172. * Adds a new optimizer to the list of optimizers
  57173. * @param optimizer defines the optimizers to add
  57174. * @returns the current material
  57175. */
  57176. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57177. /**
  57178. * Remove an optimizer from the list of optimizers
  57179. * @param optimizer defines the optimizers to remove
  57180. * @returns the current material
  57181. */
  57182. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57183. /**
  57184. * Add a new block to the list of output nodes
  57185. * @param node defines the node to add
  57186. * @returns the current material
  57187. */
  57188. addOutputNode(node: NodeMaterialBlock): this;
  57189. /**
  57190. * Remove a block from the list of root nodes
  57191. * @param node defines the node to remove
  57192. * @returns the current material
  57193. */
  57194. removeOutputNode(node: NodeMaterialBlock): this;
  57195. private _addVertexOutputNode;
  57196. private _removeVertexOutputNode;
  57197. private _addFragmentOutputNode;
  57198. private _removeFragmentOutputNode;
  57199. /**
  57200. * Specifies if the material will require alpha blending
  57201. * @returns a boolean specifying if alpha blending is needed
  57202. */
  57203. needAlphaBlending(): boolean;
  57204. /**
  57205. * Specifies if this material should be rendered in alpha test mode
  57206. * @returns a boolean specifying if an alpha test is needed.
  57207. */
  57208. needAlphaTesting(): boolean;
  57209. private _initializeBlock;
  57210. private _resetDualBlocks;
  57211. /**
  57212. * Remove a block from the current node material
  57213. * @param block defines the block to remove
  57214. */
  57215. removeBlock(block: NodeMaterialBlock): void;
  57216. /**
  57217. * Build the material and generates the inner effect
  57218. * @param verbose defines if the build should log activity
  57219. */
  57220. build(verbose?: boolean): void;
  57221. /**
  57222. * Runs an otpimization phase to try to improve the shader code
  57223. */
  57224. optimize(): void;
  57225. private _prepareDefinesForAttributes;
  57226. /**
  57227. * Get if the submesh is ready to be used and all its information available.
  57228. * Child classes can use it to update shaders
  57229. * @param mesh defines the mesh to check
  57230. * @param subMesh defines which submesh to check
  57231. * @param useInstances specifies that instances should be used
  57232. * @returns a boolean indicating that the submesh is ready or not
  57233. */
  57234. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57235. /**
  57236. * Get a string representing the shaders built by the current node graph
  57237. */
  57238. get compiledShaders(): string;
  57239. /**
  57240. * Binds the world matrix to the material
  57241. * @param world defines the world transformation matrix
  57242. */
  57243. bindOnlyWorldMatrix(world: Matrix): void;
  57244. /**
  57245. * Binds the submesh to this material by preparing the effect and shader to draw
  57246. * @param world defines the world transformation matrix
  57247. * @param mesh defines the mesh containing the submesh
  57248. * @param subMesh defines the submesh to bind the material to
  57249. */
  57250. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57251. /**
  57252. * Gets the active textures from the material
  57253. * @returns an array of textures
  57254. */
  57255. getActiveTextures(): BaseTexture[];
  57256. /**
  57257. * Gets the list of texture blocks
  57258. * @returns an array of texture blocks
  57259. */
  57260. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57261. /**
  57262. * Specifies if the material uses a texture
  57263. * @param texture defines the texture to check against the material
  57264. * @returns a boolean specifying if the material uses the texture
  57265. */
  57266. hasTexture(texture: BaseTexture): boolean;
  57267. /**
  57268. * Disposes the material
  57269. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57270. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57271. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57272. */
  57273. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57274. /** Creates the node editor window. */
  57275. private _createNodeEditor;
  57276. /**
  57277. * Launch the node material editor
  57278. * @param config Define the configuration of the editor
  57279. * @return a promise fulfilled when the node editor is visible
  57280. */
  57281. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57282. /**
  57283. * Clear the current material
  57284. */
  57285. clear(): void;
  57286. /**
  57287. * Clear the current material and set it to a default state
  57288. */
  57289. setToDefault(): void;
  57290. /**
  57291. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57292. * @param url defines the url to load from
  57293. * @returns a promise that will fullfil when the material is fully loaded
  57294. */
  57295. loadAsync(url: string): Promise<void>;
  57296. private _gatherBlocks;
  57297. /**
  57298. * Generate a string containing the code declaration required to create an equivalent of this material
  57299. * @returns a string
  57300. */
  57301. generateCode(): string;
  57302. /**
  57303. * Serializes this material in a JSON representation
  57304. * @returns the serialized material object
  57305. */
  57306. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57307. private _restoreConnections;
  57308. /**
  57309. * Clear the current graph and load a new one from a serialization object
  57310. * @param source defines the JSON representation of the material
  57311. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57312. */
  57313. loadFromSerialization(source: any, rootUrl?: string): void;
  57314. /**
  57315. * Creates a node material from parsed material data
  57316. * @param source defines the JSON representation of the material
  57317. * @param scene defines the hosting scene
  57318. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57319. * @returns a new node material
  57320. */
  57321. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57322. /**
  57323. * Creates a node material from a snippet saved in a remote file
  57324. * @param name defines the name of the material to create
  57325. * @param url defines the url to load from
  57326. * @param scene defines the hosting scene
  57327. * @returns a promise that will resolve to the new node material
  57328. */
  57329. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57330. /**
  57331. * Creates a node material from a snippet saved by the node material editor
  57332. * @param snippetId defines the snippet to load
  57333. * @param scene defines the hosting scene
  57334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57335. * @returns a promise that will resolve to the new node material
  57336. */
  57337. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57338. /**
  57339. * Creates a new node material set to default basic configuration
  57340. * @param name defines the name of the material
  57341. * @param scene defines the hosting scene
  57342. * @returns a new NodeMaterial
  57343. */
  57344. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57345. }
  57346. }
  57347. declare module BABYLON {
  57348. /**
  57349. * Block used to read a texture from a sampler
  57350. */
  57351. export class TextureBlock extends NodeMaterialBlock {
  57352. private _defineName;
  57353. private _linearDefineName;
  57354. private _tempTextureRead;
  57355. private _samplerName;
  57356. private _transformedUVName;
  57357. private _textureTransformName;
  57358. private _textureInfoName;
  57359. private _mainUVName;
  57360. private _mainUVDefineName;
  57361. /**
  57362. * Gets or sets the texture associated with the node
  57363. */
  57364. texture: Nullable<Texture>;
  57365. /**
  57366. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57367. */
  57368. convertToGammaSpace: boolean;
  57369. /**
  57370. * Create a new TextureBlock
  57371. * @param name defines the block name
  57372. */
  57373. constructor(name: string);
  57374. /**
  57375. * Gets the current class name
  57376. * @returns the class name
  57377. */
  57378. getClassName(): string;
  57379. /**
  57380. * Gets the uv input component
  57381. */
  57382. get uv(): NodeMaterialConnectionPoint;
  57383. /**
  57384. * Gets the rgba output component
  57385. */
  57386. get rgba(): NodeMaterialConnectionPoint;
  57387. /**
  57388. * Gets the rgb output component
  57389. */
  57390. get rgb(): NodeMaterialConnectionPoint;
  57391. /**
  57392. * Gets the r output component
  57393. */
  57394. get r(): NodeMaterialConnectionPoint;
  57395. /**
  57396. * Gets the g output component
  57397. */
  57398. get g(): NodeMaterialConnectionPoint;
  57399. /**
  57400. * Gets the b output component
  57401. */
  57402. get b(): NodeMaterialConnectionPoint;
  57403. /**
  57404. * Gets the a output component
  57405. */
  57406. get a(): NodeMaterialConnectionPoint;
  57407. get target(): NodeMaterialBlockTargets;
  57408. autoConfigure(material: NodeMaterial): void;
  57409. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57411. isReady(): boolean;
  57412. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57413. private get _isMixed();
  57414. private _injectVertexCode;
  57415. private _writeTextureRead;
  57416. private _writeOutput;
  57417. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57418. protected _dumpPropertiesCode(): string;
  57419. serialize(): any;
  57420. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57421. }
  57422. }
  57423. declare module BABYLON {
  57424. /**
  57425. * Class used to store shared data between 2 NodeMaterialBuildState
  57426. */
  57427. export class NodeMaterialBuildStateSharedData {
  57428. /**
  57429. * Gets the list of emitted varyings
  57430. */
  57431. temps: string[];
  57432. /**
  57433. * Gets the list of emitted varyings
  57434. */
  57435. varyings: string[];
  57436. /**
  57437. * Gets the varying declaration string
  57438. */
  57439. varyingDeclaration: string;
  57440. /**
  57441. * Input blocks
  57442. */
  57443. inputBlocks: InputBlock[];
  57444. /**
  57445. * Input blocks
  57446. */
  57447. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57448. /**
  57449. * Bindable blocks (Blocks that need to set data to the effect)
  57450. */
  57451. bindableBlocks: NodeMaterialBlock[];
  57452. /**
  57453. * List of blocks that can provide a compilation fallback
  57454. */
  57455. blocksWithFallbacks: NodeMaterialBlock[];
  57456. /**
  57457. * List of blocks that can provide a define update
  57458. */
  57459. blocksWithDefines: NodeMaterialBlock[];
  57460. /**
  57461. * List of blocks that can provide a repeatable content
  57462. */
  57463. repeatableContentBlocks: NodeMaterialBlock[];
  57464. /**
  57465. * List of blocks that can provide a dynamic list of uniforms
  57466. */
  57467. dynamicUniformBlocks: NodeMaterialBlock[];
  57468. /**
  57469. * List of blocks that can block the isReady function for the material
  57470. */
  57471. blockingBlocks: NodeMaterialBlock[];
  57472. /**
  57473. * Gets the list of animated inputs
  57474. */
  57475. animatedInputs: InputBlock[];
  57476. /**
  57477. * Build Id used to avoid multiple recompilations
  57478. */
  57479. buildId: number;
  57480. /** List of emitted variables */
  57481. variableNames: {
  57482. [key: string]: number;
  57483. };
  57484. /** List of emitted defines */
  57485. defineNames: {
  57486. [key: string]: number;
  57487. };
  57488. /** Should emit comments? */
  57489. emitComments: boolean;
  57490. /** Emit build activity */
  57491. verbose: boolean;
  57492. /** Gets or sets the hosting scene */
  57493. scene: Scene;
  57494. /**
  57495. * Gets the compilation hints emitted at compilation time
  57496. */
  57497. hints: {
  57498. needWorldViewMatrix: boolean;
  57499. needWorldViewProjectionMatrix: boolean;
  57500. needAlphaBlending: boolean;
  57501. needAlphaTesting: boolean;
  57502. };
  57503. /**
  57504. * List of compilation checks
  57505. */
  57506. checks: {
  57507. emitVertex: boolean;
  57508. emitFragment: boolean;
  57509. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57510. };
  57511. /** Creates a new shared data */
  57512. constructor();
  57513. /**
  57514. * Emits console errors and exceptions if there is a failing check
  57515. */
  57516. emitErrors(): void;
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * Class used to store node based material build state
  57522. */
  57523. export class NodeMaterialBuildState {
  57524. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57525. supportUniformBuffers: boolean;
  57526. /**
  57527. * Gets the list of emitted attributes
  57528. */
  57529. attributes: string[];
  57530. /**
  57531. * Gets the list of emitted uniforms
  57532. */
  57533. uniforms: string[];
  57534. /**
  57535. * Gets the list of emitted constants
  57536. */
  57537. constants: string[];
  57538. /**
  57539. * Gets the list of emitted samplers
  57540. */
  57541. samplers: string[];
  57542. /**
  57543. * Gets the list of emitted functions
  57544. */
  57545. functions: {
  57546. [key: string]: string;
  57547. };
  57548. /**
  57549. * Gets the list of emitted extensions
  57550. */
  57551. extensions: {
  57552. [key: string]: string;
  57553. };
  57554. /**
  57555. * Gets the target of the compilation state
  57556. */
  57557. target: NodeMaterialBlockTargets;
  57558. /**
  57559. * Gets the list of emitted counters
  57560. */
  57561. counters: {
  57562. [key: string]: number;
  57563. };
  57564. /**
  57565. * Shared data between multiple NodeMaterialBuildState instances
  57566. */
  57567. sharedData: NodeMaterialBuildStateSharedData;
  57568. /** @hidden */
  57569. _vertexState: NodeMaterialBuildState;
  57570. /** @hidden */
  57571. _attributeDeclaration: string;
  57572. /** @hidden */
  57573. _uniformDeclaration: string;
  57574. /** @hidden */
  57575. _constantDeclaration: string;
  57576. /** @hidden */
  57577. _samplerDeclaration: string;
  57578. /** @hidden */
  57579. _varyingTransfer: string;
  57580. private _repeatableContentAnchorIndex;
  57581. /** @hidden */
  57582. _builtCompilationString: string;
  57583. /**
  57584. * Gets the emitted compilation strings
  57585. */
  57586. compilationString: string;
  57587. /**
  57588. * Finalize the compilation strings
  57589. * @param state defines the current compilation state
  57590. */
  57591. finalize(state: NodeMaterialBuildState): void;
  57592. /** @hidden */
  57593. get _repeatableContentAnchor(): string;
  57594. /** @hidden */
  57595. _getFreeVariableName(prefix: string): string;
  57596. /** @hidden */
  57597. _getFreeDefineName(prefix: string): string;
  57598. /** @hidden */
  57599. _excludeVariableName(name: string): void;
  57600. /** @hidden */
  57601. _emit2DSampler(name: string): void;
  57602. /** @hidden */
  57603. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57604. /** @hidden */
  57605. _emitExtension(name: string, extension: string): void;
  57606. /** @hidden */
  57607. _emitFunction(name: string, code: string, comments: string): void;
  57608. /** @hidden */
  57609. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57610. replaceStrings?: {
  57611. search: RegExp;
  57612. replace: string;
  57613. }[];
  57614. repeatKey?: string;
  57615. }): string;
  57616. /** @hidden */
  57617. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57618. repeatKey?: string;
  57619. removeAttributes?: boolean;
  57620. removeUniforms?: boolean;
  57621. removeVaryings?: boolean;
  57622. removeIfDef?: boolean;
  57623. replaceStrings?: {
  57624. search: RegExp;
  57625. replace: string;
  57626. }[];
  57627. }, storeKey?: string): void;
  57628. /** @hidden */
  57629. _registerTempVariable(name: string): boolean;
  57630. /** @hidden */
  57631. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57632. /** @hidden */
  57633. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57634. /** @hidden */
  57635. _emitFloat(value: number): string;
  57636. }
  57637. }
  57638. declare module BABYLON {
  57639. /**
  57640. * Defines a block that can be used inside a node based material
  57641. */
  57642. export class NodeMaterialBlock {
  57643. private _buildId;
  57644. private _buildTarget;
  57645. private _target;
  57646. private _isFinalMerger;
  57647. private _isInput;
  57648. protected _isUnique: boolean;
  57649. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57650. inputsAreExclusive: boolean;
  57651. /** @hidden */
  57652. _codeVariableName: string;
  57653. /** @hidden */
  57654. _inputs: NodeMaterialConnectionPoint[];
  57655. /** @hidden */
  57656. _outputs: NodeMaterialConnectionPoint[];
  57657. /** @hidden */
  57658. _preparationId: number;
  57659. /**
  57660. * Gets or sets the name of the block
  57661. */
  57662. name: string;
  57663. /**
  57664. * Gets or sets the unique id of the node
  57665. */
  57666. uniqueId: number;
  57667. /**
  57668. * Gets or sets the comments associated with this block
  57669. */
  57670. comments: string;
  57671. /**
  57672. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57673. */
  57674. get isUnique(): boolean;
  57675. /**
  57676. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57677. */
  57678. get isFinalMerger(): boolean;
  57679. /**
  57680. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57681. */
  57682. get isInput(): boolean;
  57683. /**
  57684. * Gets or sets the build Id
  57685. */
  57686. get buildId(): number;
  57687. set buildId(value: number);
  57688. /**
  57689. * Gets or sets the target of the block
  57690. */
  57691. get target(): NodeMaterialBlockTargets;
  57692. set target(value: NodeMaterialBlockTargets);
  57693. /**
  57694. * Gets the list of input points
  57695. */
  57696. get inputs(): NodeMaterialConnectionPoint[];
  57697. /** Gets the list of output points */
  57698. get outputs(): NodeMaterialConnectionPoint[];
  57699. /**
  57700. * Find an input by its name
  57701. * @param name defines the name of the input to look for
  57702. * @returns the input or null if not found
  57703. */
  57704. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57705. /**
  57706. * Find an output by its name
  57707. * @param name defines the name of the outputto look for
  57708. * @returns the output or null if not found
  57709. */
  57710. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57711. /**
  57712. * Creates a new NodeMaterialBlock
  57713. * @param name defines the block name
  57714. * @param target defines the target of that block (Vertex by default)
  57715. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57716. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57717. */
  57718. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57719. /**
  57720. * Initialize the block and prepare the context for build
  57721. * @param state defines the state that will be used for the build
  57722. */
  57723. initialize(state: NodeMaterialBuildState): void;
  57724. /**
  57725. * Bind data to effect. Will only be called for blocks with isBindable === true
  57726. * @param effect defines the effect to bind data to
  57727. * @param nodeMaterial defines the hosting NodeMaterial
  57728. * @param mesh defines the mesh that will be rendered
  57729. */
  57730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57731. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57732. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57733. protected _writeFloat(value: number): string;
  57734. /**
  57735. * Gets the current class name e.g. "NodeMaterialBlock"
  57736. * @returns the class name
  57737. */
  57738. getClassName(): string;
  57739. /**
  57740. * Register a new input. Must be called inside a block constructor
  57741. * @param name defines the connection point name
  57742. * @param type defines the connection point type
  57743. * @param isOptional defines a boolean indicating that this input can be omitted
  57744. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57745. * @returns the current block
  57746. */
  57747. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57748. /**
  57749. * Register a new output. Must be called inside a block constructor
  57750. * @param name defines the connection point name
  57751. * @param type defines the connection point type
  57752. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57753. * @returns the current block
  57754. */
  57755. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57756. /**
  57757. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57758. * @param forOutput defines an optional connection point to check compatibility with
  57759. * @returns the first available input or null
  57760. */
  57761. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57762. /**
  57763. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57764. * @param forBlock defines an optional block to check compatibility with
  57765. * @returns the first available input or null
  57766. */
  57767. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57768. /**
  57769. * Gets the sibling of the given output
  57770. * @param current defines the current output
  57771. * @returns the next output in the list or null
  57772. */
  57773. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57774. /**
  57775. * Connect current block with another block
  57776. * @param other defines the block to connect with
  57777. * @param options define the various options to help pick the right connections
  57778. * @returns the current block
  57779. */
  57780. connectTo(other: NodeMaterialBlock, options?: {
  57781. input?: string;
  57782. output?: string;
  57783. outputSwizzle?: string;
  57784. }): this | undefined;
  57785. protected _buildBlock(state: NodeMaterialBuildState): void;
  57786. /**
  57787. * Add uniforms, samplers and uniform buffers at compilation time
  57788. * @param state defines the state to update
  57789. * @param nodeMaterial defines the node material requesting the update
  57790. * @param defines defines the material defines to update
  57791. * @param uniformBuffers defines the list of uniform buffer names
  57792. */
  57793. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57794. /**
  57795. * Add potential fallbacks if shader compilation fails
  57796. * @param mesh defines the mesh to be rendered
  57797. * @param fallbacks defines the current prioritized list of fallbacks
  57798. */
  57799. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57800. /**
  57801. * Initialize defines for shader compilation
  57802. * @param mesh defines the mesh to be rendered
  57803. * @param nodeMaterial defines the node material requesting the update
  57804. * @param defines defines the material defines to update
  57805. * @param useInstances specifies that instances should be used
  57806. */
  57807. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57808. /**
  57809. * Update defines for shader compilation
  57810. * @param mesh defines the mesh to be rendered
  57811. * @param nodeMaterial defines the node material requesting the update
  57812. * @param defines defines the material defines to update
  57813. * @param useInstances specifies that instances should be used
  57814. */
  57815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57816. /**
  57817. * Lets the block try to connect some inputs automatically
  57818. * @param material defines the hosting NodeMaterial
  57819. */
  57820. autoConfigure(material: NodeMaterial): void;
  57821. /**
  57822. * Function called when a block is declared as repeatable content generator
  57823. * @param vertexShaderState defines the current compilation state for the vertex shader
  57824. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57825. * @param mesh defines the mesh to be rendered
  57826. * @param defines defines the material defines to update
  57827. */
  57828. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57829. /**
  57830. * Checks if the block is ready
  57831. * @param mesh defines the mesh to be rendered
  57832. * @param nodeMaterial defines the node material requesting the update
  57833. * @param defines defines the material defines to update
  57834. * @param useInstances specifies that instances should be used
  57835. * @returns true if the block is ready
  57836. */
  57837. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57838. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57839. private _processBuild;
  57840. /**
  57841. * Compile the current node and generate the shader code
  57842. * @param state defines the current compilation state (uniforms, samplers, current string)
  57843. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57844. * @returns true if already built
  57845. */
  57846. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57847. protected _inputRename(name: string): string;
  57848. protected _outputRename(name: string): string;
  57849. protected _dumpPropertiesCode(): string;
  57850. /** @hidden */
  57851. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57852. /** @hidden */
  57853. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57854. /**
  57855. * Clone the current block to a new identical block
  57856. * @param scene defines the hosting scene
  57857. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57858. * @returns a copy of the current block
  57859. */
  57860. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57861. /**
  57862. * Serializes this block in a JSON representation
  57863. * @returns the serialized block object
  57864. */
  57865. serialize(): any;
  57866. /** @hidden */
  57867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57868. /**
  57869. * Release resources
  57870. */
  57871. dispose(): void;
  57872. }
  57873. }
  57874. declare module BABYLON {
  57875. /**
  57876. * Enum defining the type of animations supported by InputBlock
  57877. */
  57878. export enum AnimatedInputBlockTypes {
  57879. /** No animation */
  57880. None = 0,
  57881. /** Time based animation. Will only work for floats */
  57882. Time = 1
  57883. }
  57884. }
  57885. declare module BABYLON {
  57886. /**
  57887. * Block used to expose an input value
  57888. */
  57889. export class InputBlock extends NodeMaterialBlock {
  57890. private _mode;
  57891. private _associatedVariableName;
  57892. private _storedValue;
  57893. private _valueCallback;
  57894. private _type;
  57895. private _animationType;
  57896. /** Gets or set a value used to limit the range of float values */
  57897. min: number;
  57898. /** Gets or set a value used to limit the range of float values */
  57899. max: number;
  57900. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57901. isBoolean: boolean;
  57902. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57903. matrixMode: number;
  57904. /** @hidden */
  57905. _systemValue: Nullable<NodeMaterialSystemValues>;
  57906. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57907. visibleInInspector: boolean;
  57908. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57909. isConstant: boolean;
  57910. /** Gets or sets the group to use to display this block in the Inspector */
  57911. groupInInspector: string;
  57912. /**
  57913. * Gets or sets the connection point type (default is float)
  57914. */
  57915. get type(): NodeMaterialBlockConnectionPointTypes;
  57916. /**
  57917. * Creates a new InputBlock
  57918. * @param name defines the block name
  57919. * @param target defines the target of that block (Vertex by default)
  57920. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57921. */
  57922. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57923. /**
  57924. * Gets the output component
  57925. */
  57926. get output(): NodeMaterialConnectionPoint;
  57927. /**
  57928. * Set the source of this connection point to a vertex attribute
  57929. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57930. * @returns the current connection point
  57931. */
  57932. setAsAttribute(attributeName?: string): InputBlock;
  57933. /**
  57934. * Set the source of this connection point to a system value
  57935. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57936. * @returns the current connection point
  57937. */
  57938. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57939. /**
  57940. * Gets or sets the value of that point.
  57941. * Please note that this value will be ignored if valueCallback is defined
  57942. */
  57943. get value(): any;
  57944. set value(value: any);
  57945. /**
  57946. * Gets or sets a callback used to get the value of that point.
  57947. * Please note that setting this value will force the connection point to ignore the value property
  57948. */
  57949. get valueCallback(): () => any;
  57950. set valueCallback(value: () => any);
  57951. /**
  57952. * Gets or sets the associated variable name in the shader
  57953. */
  57954. get associatedVariableName(): string;
  57955. set associatedVariableName(value: string);
  57956. /** Gets or sets the type of animation applied to the input */
  57957. get animationType(): AnimatedInputBlockTypes;
  57958. set animationType(value: AnimatedInputBlockTypes);
  57959. /**
  57960. * Gets a boolean indicating that this connection point not defined yet
  57961. */
  57962. get isUndefined(): boolean;
  57963. /**
  57964. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57965. * In this case the connection point name must be the name of the uniform to use.
  57966. * Can only be set on inputs
  57967. */
  57968. get isUniform(): boolean;
  57969. set isUniform(value: boolean);
  57970. /**
  57971. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57972. * In this case the connection point name must be the name of the attribute to use
  57973. * Can only be set on inputs
  57974. */
  57975. get isAttribute(): boolean;
  57976. set isAttribute(value: boolean);
  57977. /**
  57978. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57979. * Can only be set on exit points
  57980. */
  57981. get isVarying(): boolean;
  57982. set isVarying(value: boolean);
  57983. /**
  57984. * Gets a boolean indicating that the current connection point is a system value
  57985. */
  57986. get isSystemValue(): boolean;
  57987. /**
  57988. * Gets or sets the current well known value or null if not defined as a system value
  57989. */
  57990. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57991. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57992. /**
  57993. * Gets the current class name
  57994. * @returns the class name
  57995. */
  57996. getClassName(): string;
  57997. /**
  57998. * Animate the input if animationType !== None
  57999. * @param scene defines the rendering scene
  58000. */
  58001. animate(scene: Scene): void;
  58002. private _emitDefine;
  58003. initialize(state: NodeMaterialBuildState): void;
  58004. /**
  58005. * Set the input block to its default value (based on its type)
  58006. */
  58007. setDefaultValue(): void;
  58008. private _emitConstant;
  58009. private _emit;
  58010. /** @hidden */
  58011. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58012. /** @hidden */
  58013. _transmit(effect: Effect, scene: Scene): void;
  58014. protected _buildBlock(state: NodeMaterialBuildState): void;
  58015. protected _dumpPropertiesCode(): string;
  58016. serialize(): any;
  58017. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58018. }
  58019. }
  58020. declare module BABYLON {
  58021. /**
  58022. * Enum used to define the compatibility state between two connection points
  58023. */
  58024. export enum NodeMaterialConnectionPointCompatibilityStates {
  58025. /** Points are compatibles */
  58026. Compatible = 0,
  58027. /** Points are incompatible because of their types */
  58028. TypeIncompatible = 1,
  58029. /** Points are incompatible because of their targets (vertex vs fragment) */
  58030. TargetIncompatible = 2
  58031. }
  58032. /**
  58033. * Defines the direction of a connection point
  58034. */
  58035. export enum NodeMaterialConnectionPointDirection {
  58036. /** Input */
  58037. Input = 0,
  58038. /** Output */
  58039. Output = 1
  58040. }
  58041. /**
  58042. * Defines a connection point for a block
  58043. */
  58044. export class NodeMaterialConnectionPoint {
  58045. /** @hidden */
  58046. _ownerBlock: NodeMaterialBlock;
  58047. /** @hidden */
  58048. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58049. private _endpoints;
  58050. private _associatedVariableName;
  58051. private _direction;
  58052. /** @hidden */
  58053. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58054. /** @hidden */
  58055. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58056. private _type;
  58057. /** @hidden */
  58058. _enforceAssociatedVariableName: boolean;
  58059. /** Gets the direction of the point */
  58060. get direction(): NodeMaterialConnectionPointDirection;
  58061. /**
  58062. * Gets or sets the additional types supported by this connection point
  58063. */
  58064. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58065. /**
  58066. * Gets or sets the additional types excluded by this connection point
  58067. */
  58068. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58069. /**
  58070. * Observable triggered when this point is connected
  58071. */
  58072. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58073. /**
  58074. * Gets or sets the associated variable name in the shader
  58075. */
  58076. get associatedVariableName(): string;
  58077. set associatedVariableName(value: string);
  58078. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58079. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58080. /**
  58081. * Gets or sets the connection point type (default is float)
  58082. */
  58083. get type(): NodeMaterialBlockConnectionPointTypes;
  58084. set type(value: NodeMaterialBlockConnectionPointTypes);
  58085. /**
  58086. * Gets or sets the connection point name
  58087. */
  58088. name: string;
  58089. /**
  58090. * Gets or sets a boolean indicating that this connection point can be omitted
  58091. */
  58092. isOptional: boolean;
  58093. /**
  58094. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58095. */
  58096. define: string;
  58097. /** @hidden */
  58098. _prioritizeVertex: boolean;
  58099. private _target;
  58100. /** Gets or sets the target of that connection point */
  58101. get target(): NodeMaterialBlockTargets;
  58102. set target(value: NodeMaterialBlockTargets);
  58103. /**
  58104. * Gets a boolean indicating that the current point is connected
  58105. */
  58106. get isConnected(): boolean;
  58107. /**
  58108. * Gets a boolean indicating that the current point is connected to an input block
  58109. */
  58110. get isConnectedToInputBlock(): boolean;
  58111. /**
  58112. * Gets a the connected input block (if any)
  58113. */
  58114. get connectInputBlock(): Nullable<InputBlock>;
  58115. /** Get the other side of the connection (if any) */
  58116. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58117. /** Get the block that owns this connection point */
  58118. get ownerBlock(): NodeMaterialBlock;
  58119. /** Get the block connected on the other side of this connection (if any) */
  58120. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58121. /** Get the block connected on the endpoints of this connection (if any) */
  58122. get connectedBlocks(): Array<NodeMaterialBlock>;
  58123. /** Gets the list of connected endpoints */
  58124. get endpoints(): NodeMaterialConnectionPoint[];
  58125. /** Gets a boolean indicating if that output point is connected to at least one input */
  58126. get hasEndpoints(): boolean;
  58127. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58128. get isConnectedInVertexShader(): boolean;
  58129. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58130. get isConnectedInFragmentShader(): boolean;
  58131. /**
  58132. * Creates a new connection point
  58133. * @param name defines the connection point name
  58134. * @param ownerBlock defines the block hosting this connection point
  58135. * @param direction defines the direction of the connection point
  58136. */
  58137. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58138. /**
  58139. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58140. * @returns the class name
  58141. */
  58142. getClassName(): string;
  58143. /**
  58144. * Gets a boolean indicating if the current point can be connected to another point
  58145. * @param connectionPoint defines the other connection point
  58146. * @returns a boolean
  58147. */
  58148. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58149. /**
  58150. * Gets a number indicating if the current point can be connected to another point
  58151. * @param connectionPoint defines the other connection point
  58152. * @returns a number defining the compatibility state
  58153. */
  58154. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58155. /**
  58156. * Connect this point to another connection point
  58157. * @param connectionPoint defines the other connection point
  58158. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58159. * @returns the current connection point
  58160. */
  58161. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58162. /**
  58163. * Disconnect this point from one of his endpoint
  58164. * @param endpoint defines the other connection point
  58165. * @returns the current connection point
  58166. */
  58167. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58168. /**
  58169. * Serializes this point in a JSON representation
  58170. * @returns the serialized point object
  58171. */
  58172. serialize(): any;
  58173. /**
  58174. * Release resources
  58175. */
  58176. dispose(): void;
  58177. }
  58178. }
  58179. declare module BABYLON {
  58180. /**
  58181. * Block used to add support for vertex skinning (bones)
  58182. */
  58183. export class BonesBlock extends NodeMaterialBlock {
  58184. /**
  58185. * Creates a new BonesBlock
  58186. * @param name defines the block name
  58187. */
  58188. constructor(name: string);
  58189. /**
  58190. * Initialize the block and prepare the context for build
  58191. * @param state defines the state that will be used for the build
  58192. */
  58193. initialize(state: NodeMaterialBuildState): void;
  58194. /**
  58195. * Gets the current class name
  58196. * @returns the class name
  58197. */
  58198. getClassName(): string;
  58199. /**
  58200. * Gets the matrix indices input component
  58201. */
  58202. get matricesIndices(): NodeMaterialConnectionPoint;
  58203. /**
  58204. * Gets the matrix weights input component
  58205. */
  58206. get matricesWeights(): NodeMaterialConnectionPoint;
  58207. /**
  58208. * Gets the extra matrix indices input component
  58209. */
  58210. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58211. /**
  58212. * Gets the extra matrix weights input component
  58213. */
  58214. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58215. /**
  58216. * Gets the world input component
  58217. */
  58218. get world(): NodeMaterialConnectionPoint;
  58219. /**
  58220. * Gets the output component
  58221. */
  58222. get output(): NodeMaterialConnectionPoint;
  58223. autoConfigure(material: NodeMaterial): void;
  58224. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58225. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58227. protected _buildBlock(state: NodeMaterialBuildState): this;
  58228. }
  58229. }
  58230. declare module BABYLON {
  58231. /**
  58232. * Block used to add support for instances
  58233. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58234. */
  58235. export class InstancesBlock extends NodeMaterialBlock {
  58236. /**
  58237. * Creates a new InstancesBlock
  58238. * @param name defines the block name
  58239. */
  58240. constructor(name: string);
  58241. /**
  58242. * Gets the current class name
  58243. * @returns the class name
  58244. */
  58245. getClassName(): string;
  58246. /**
  58247. * Gets the first world row input component
  58248. */
  58249. get world0(): NodeMaterialConnectionPoint;
  58250. /**
  58251. * Gets the second world row input component
  58252. */
  58253. get world1(): NodeMaterialConnectionPoint;
  58254. /**
  58255. * Gets the third world row input component
  58256. */
  58257. get world2(): NodeMaterialConnectionPoint;
  58258. /**
  58259. * Gets the forth world row input component
  58260. */
  58261. get world3(): NodeMaterialConnectionPoint;
  58262. /**
  58263. * Gets the world input component
  58264. */
  58265. get world(): NodeMaterialConnectionPoint;
  58266. /**
  58267. * Gets the output component
  58268. */
  58269. get output(): NodeMaterialConnectionPoint;
  58270. /**
  58271. * Gets the isntanceID component
  58272. */
  58273. get instanceID(): NodeMaterialConnectionPoint;
  58274. autoConfigure(material: NodeMaterial): void;
  58275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58276. protected _buildBlock(state: NodeMaterialBuildState): this;
  58277. }
  58278. }
  58279. declare module BABYLON {
  58280. /**
  58281. * Block used to add morph targets support to vertex shader
  58282. */
  58283. export class MorphTargetsBlock extends NodeMaterialBlock {
  58284. private _repeatableContentAnchor;
  58285. /**
  58286. * Create a new MorphTargetsBlock
  58287. * @param name defines the block name
  58288. */
  58289. constructor(name: string);
  58290. /**
  58291. * Gets the current class name
  58292. * @returns the class name
  58293. */
  58294. getClassName(): string;
  58295. /**
  58296. * Gets the position input component
  58297. */
  58298. get position(): NodeMaterialConnectionPoint;
  58299. /**
  58300. * Gets the normal input component
  58301. */
  58302. get normal(): NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the tangent input component
  58305. */
  58306. get tangent(): NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the tangent input component
  58309. */
  58310. get uv(): NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the position output component
  58313. */
  58314. get positionOutput(): NodeMaterialConnectionPoint;
  58315. /**
  58316. * Gets the normal output component
  58317. */
  58318. get normalOutput(): NodeMaterialConnectionPoint;
  58319. /**
  58320. * Gets the tangent output component
  58321. */
  58322. get tangentOutput(): NodeMaterialConnectionPoint;
  58323. /**
  58324. * Gets the tangent output component
  58325. */
  58326. get uvOutput(): NodeMaterialConnectionPoint;
  58327. initialize(state: NodeMaterialBuildState): void;
  58328. autoConfigure(material: NodeMaterial): void;
  58329. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58330. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58331. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58332. protected _buildBlock(state: NodeMaterialBuildState): this;
  58333. }
  58334. }
  58335. declare module BABYLON {
  58336. /**
  58337. * Block used to get data information from a light
  58338. */
  58339. export class LightInformationBlock extends NodeMaterialBlock {
  58340. private _lightDataUniformName;
  58341. private _lightColorUniformName;
  58342. private _lightTypeDefineName;
  58343. /**
  58344. * Gets or sets the light associated with this block
  58345. */
  58346. light: Nullable<Light>;
  58347. /**
  58348. * Creates a new LightInformationBlock
  58349. * @param name defines the block name
  58350. */
  58351. constructor(name: string);
  58352. /**
  58353. * Gets the current class name
  58354. * @returns the class name
  58355. */
  58356. getClassName(): string;
  58357. /**
  58358. * Gets the world position input component
  58359. */
  58360. get worldPosition(): NodeMaterialConnectionPoint;
  58361. /**
  58362. * Gets the direction output component
  58363. */
  58364. get direction(): NodeMaterialConnectionPoint;
  58365. /**
  58366. * Gets the direction output component
  58367. */
  58368. get color(): NodeMaterialConnectionPoint;
  58369. /**
  58370. * Gets the direction output component
  58371. */
  58372. get intensity(): NodeMaterialConnectionPoint;
  58373. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58374. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58375. protected _buildBlock(state: NodeMaterialBuildState): this;
  58376. serialize(): any;
  58377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58378. }
  58379. }
  58380. declare module BABYLON {
  58381. /**
  58382. * Block used to add image processing support to fragment shader
  58383. */
  58384. export class ImageProcessingBlock extends NodeMaterialBlock {
  58385. /**
  58386. * Create a new ImageProcessingBlock
  58387. * @param name defines the block name
  58388. */
  58389. constructor(name: string);
  58390. /**
  58391. * Gets the current class name
  58392. * @returns the class name
  58393. */
  58394. getClassName(): string;
  58395. /**
  58396. * Gets the color input component
  58397. */
  58398. get color(): NodeMaterialConnectionPoint;
  58399. /**
  58400. * Gets the output component
  58401. */
  58402. get output(): NodeMaterialConnectionPoint;
  58403. /**
  58404. * Initialize the block and prepare the context for build
  58405. * @param state defines the state that will be used for the build
  58406. */
  58407. initialize(state: NodeMaterialBuildState): void;
  58408. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58409. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58410. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58411. protected _buildBlock(state: NodeMaterialBuildState): this;
  58412. }
  58413. }
  58414. declare module BABYLON {
  58415. /**
  58416. * Block used to pertub normals based on a normal map
  58417. */
  58418. export class PerturbNormalBlock extends NodeMaterialBlock {
  58419. private _tangentSpaceParameterName;
  58420. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58421. invertX: boolean;
  58422. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58423. invertY: boolean;
  58424. /**
  58425. * Create a new PerturbNormalBlock
  58426. * @param name defines the block name
  58427. */
  58428. constructor(name: string);
  58429. /**
  58430. * Gets the current class name
  58431. * @returns the class name
  58432. */
  58433. getClassName(): string;
  58434. /**
  58435. * Gets the world position input component
  58436. */
  58437. get worldPosition(): NodeMaterialConnectionPoint;
  58438. /**
  58439. * Gets the world normal input component
  58440. */
  58441. get worldNormal(): NodeMaterialConnectionPoint;
  58442. /**
  58443. * Gets the world tangent input component
  58444. */
  58445. get worldTangent(): NodeMaterialConnectionPoint;
  58446. /**
  58447. * Gets the uv input component
  58448. */
  58449. get uv(): NodeMaterialConnectionPoint;
  58450. /**
  58451. * Gets the normal map color input component
  58452. */
  58453. get normalMapColor(): NodeMaterialConnectionPoint;
  58454. /**
  58455. * Gets the strength input component
  58456. */
  58457. get strength(): NodeMaterialConnectionPoint;
  58458. /**
  58459. * Gets the output component
  58460. */
  58461. get output(): NodeMaterialConnectionPoint;
  58462. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58463. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58464. autoConfigure(material: NodeMaterial): void;
  58465. protected _buildBlock(state: NodeMaterialBuildState): this;
  58466. protected _dumpPropertiesCode(): string;
  58467. serialize(): any;
  58468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58469. }
  58470. }
  58471. declare module BABYLON {
  58472. /**
  58473. * Block used to discard a pixel if a value is smaller than a cutoff
  58474. */
  58475. export class DiscardBlock extends NodeMaterialBlock {
  58476. /**
  58477. * Create a new DiscardBlock
  58478. * @param name defines the block name
  58479. */
  58480. constructor(name: string);
  58481. /**
  58482. * Gets the current class name
  58483. * @returns the class name
  58484. */
  58485. getClassName(): string;
  58486. /**
  58487. * Gets the color input component
  58488. */
  58489. get value(): NodeMaterialConnectionPoint;
  58490. /**
  58491. * Gets the cutoff input component
  58492. */
  58493. get cutoff(): NodeMaterialConnectionPoint;
  58494. protected _buildBlock(state: NodeMaterialBuildState): this;
  58495. }
  58496. }
  58497. declare module BABYLON {
  58498. /**
  58499. * Block used to test if the fragment shader is front facing
  58500. */
  58501. export class FrontFacingBlock extends NodeMaterialBlock {
  58502. /**
  58503. * Creates a new FrontFacingBlock
  58504. * @param name defines the block name
  58505. */
  58506. constructor(name: string);
  58507. /**
  58508. * Gets the current class name
  58509. * @returns the class name
  58510. */
  58511. getClassName(): string;
  58512. /**
  58513. * Gets the output component
  58514. */
  58515. get output(): NodeMaterialConnectionPoint;
  58516. protected _buildBlock(state: NodeMaterialBuildState): this;
  58517. }
  58518. }
  58519. declare module BABYLON {
  58520. /**
  58521. * Block used to get the derivative value on x and y of a given input
  58522. */
  58523. export class DerivativeBlock extends NodeMaterialBlock {
  58524. /**
  58525. * Create a new DerivativeBlock
  58526. * @param name defines the block name
  58527. */
  58528. constructor(name: string);
  58529. /**
  58530. * Gets the current class name
  58531. * @returns the class name
  58532. */
  58533. getClassName(): string;
  58534. /**
  58535. * Gets the input component
  58536. */
  58537. get input(): NodeMaterialConnectionPoint;
  58538. /**
  58539. * Gets the derivative output on x
  58540. */
  58541. get dx(): NodeMaterialConnectionPoint;
  58542. /**
  58543. * Gets the derivative output on y
  58544. */
  58545. get dy(): NodeMaterialConnectionPoint;
  58546. protected _buildBlock(state: NodeMaterialBuildState): this;
  58547. }
  58548. }
  58549. declare module BABYLON {
  58550. /**
  58551. * Block used to add support for scene fog
  58552. */
  58553. export class FogBlock extends NodeMaterialBlock {
  58554. private _fogDistanceName;
  58555. private _fogParameters;
  58556. /**
  58557. * Create a new FogBlock
  58558. * @param name defines the block name
  58559. */
  58560. constructor(name: string);
  58561. /**
  58562. * Gets the current class name
  58563. * @returns the class name
  58564. */
  58565. getClassName(): string;
  58566. /**
  58567. * Gets the world position input component
  58568. */
  58569. get worldPosition(): NodeMaterialConnectionPoint;
  58570. /**
  58571. * Gets the view input component
  58572. */
  58573. get view(): NodeMaterialConnectionPoint;
  58574. /**
  58575. * Gets the color input component
  58576. */
  58577. get input(): NodeMaterialConnectionPoint;
  58578. /**
  58579. * Gets the fog color input component
  58580. */
  58581. get fogColor(): NodeMaterialConnectionPoint;
  58582. /**
  58583. * Gets the output component
  58584. */
  58585. get output(): NodeMaterialConnectionPoint;
  58586. autoConfigure(material: NodeMaterial): void;
  58587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58588. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58589. protected _buildBlock(state: NodeMaterialBuildState): this;
  58590. }
  58591. }
  58592. declare module BABYLON {
  58593. /**
  58594. * Block used to add light in the fragment shader
  58595. */
  58596. export class LightBlock extends NodeMaterialBlock {
  58597. private _lightId;
  58598. /**
  58599. * Gets or sets the light associated with this block
  58600. */
  58601. light: Nullable<Light>;
  58602. /**
  58603. * Create a new LightBlock
  58604. * @param name defines the block name
  58605. */
  58606. constructor(name: string);
  58607. /**
  58608. * Gets the current class name
  58609. * @returns the class name
  58610. */
  58611. getClassName(): string;
  58612. /**
  58613. * Gets the world position input component
  58614. */
  58615. get worldPosition(): NodeMaterialConnectionPoint;
  58616. /**
  58617. * Gets the world normal input component
  58618. */
  58619. get worldNormal(): NodeMaterialConnectionPoint;
  58620. /**
  58621. * Gets the camera (or eye) position component
  58622. */
  58623. get cameraPosition(): NodeMaterialConnectionPoint;
  58624. /**
  58625. * Gets the glossiness component
  58626. */
  58627. get glossiness(): NodeMaterialConnectionPoint;
  58628. /**
  58629. * Gets the glossinness power component
  58630. */
  58631. get glossPower(): NodeMaterialConnectionPoint;
  58632. /**
  58633. * Gets the diffuse color component
  58634. */
  58635. get diffuseColor(): NodeMaterialConnectionPoint;
  58636. /**
  58637. * Gets the specular color component
  58638. */
  58639. get specularColor(): NodeMaterialConnectionPoint;
  58640. /**
  58641. * Gets the diffuse output component
  58642. */
  58643. get diffuseOutput(): NodeMaterialConnectionPoint;
  58644. /**
  58645. * Gets the specular output component
  58646. */
  58647. get specularOutput(): NodeMaterialConnectionPoint;
  58648. /**
  58649. * Gets the shadow output component
  58650. */
  58651. get shadow(): NodeMaterialConnectionPoint;
  58652. autoConfigure(material: NodeMaterial): void;
  58653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58654. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58655. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58656. private _injectVertexCode;
  58657. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58658. serialize(): any;
  58659. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58660. }
  58661. }
  58662. declare module BABYLON {
  58663. /**
  58664. * Block used to multiply 2 values
  58665. */
  58666. export class MultiplyBlock extends NodeMaterialBlock {
  58667. /**
  58668. * Creates a new MultiplyBlock
  58669. * @param name defines the block name
  58670. */
  58671. constructor(name: string);
  58672. /**
  58673. * Gets the current class name
  58674. * @returns the class name
  58675. */
  58676. getClassName(): string;
  58677. /**
  58678. * Gets the left operand input component
  58679. */
  58680. get left(): NodeMaterialConnectionPoint;
  58681. /**
  58682. * Gets the right operand input component
  58683. */
  58684. get right(): NodeMaterialConnectionPoint;
  58685. /**
  58686. * Gets the output component
  58687. */
  58688. get output(): NodeMaterialConnectionPoint;
  58689. protected _buildBlock(state: NodeMaterialBuildState): this;
  58690. }
  58691. }
  58692. declare module BABYLON {
  58693. /**
  58694. * Block used to add 2 vectors
  58695. */
  58696. export class AddBlock extends NodeMaterialBlock {
  58697. /**
  58698. * Creates a new AddBlock
  58699. * @param name defines the block name
  58700. */
  58701. constructor(name: string);
  58702. /**
  58703. * Gets the current class name
  58704. * @returns the class name
  58705. */
  58706. getClassName(): string;
  58707. /**
  58708. * Gets the left operand input component
  58709. */
  58710. get left(): NodeMaterialConnectionPoint;
  58711. /**
  58712. * Gets the right operand input component
  58713. */
  58714. get right(): NodeMaterialConnectionPoint;
  58715. /**
  58716. * Gets the output component
  58717. */
  58718. get output(): NodeMaterialConnectionPoint;
  58719. protected _buildBlock(state: NodeMaterialBuildState): this;
  58720. }
  58721. }
  58722. declare module BABYLON {
  58723. /**
  58724. * Block used to scale a vector by a float
  58725. */
  58726. export class ScaleBlock extends NodeMaterialBlock {
  58727. /**
  58728. * Creates a new ScaleBlock
  58729. * @param name defines the block name
  58730. */
  58731. constructor(name: string);
  58732. /**
  58733. * Gets the current class name
  58734. * @returns the class name
  58735. */
  58736. getClassName(): string;
  58737. /**
  58738. * Gets the input component
  58739. */
  58740. get input(): NodeMaterialConnectionPoint;
  58741. /**
  58742. * Gets the factor input component
  58743. */
  58744. get factor(): NodeMaterialConnectionPoint;
  58745. /**
  58746. * Gets the output component
  58747. */
  58748. get output(): NodeMaterialConnectionPoint;
  58749. protected _buildBlock(state: NodeMaterialBuildState): this;
  58750. }
  58751. }
  58752. declare module BABYLON {
  58753. /**
  58754. * Block used to clamp a float
  58755. */
  58756. export class ClampBlock extends NodeMaterialBlock {
  58757. /** Gets or sets the minimum range */
  58758. minimum: number;
  58759. /** Gets or sets the maximum range */
  58760. maximum: number;
  58761. /**
  58762. * Creates a new ClampBlock
  58763. * @param name defines the block name
  58764. */
  58765. constructor(name: string);
  58766. /**
  58767. * Gets the current class name
  58768. * @returns the class name
  58769. */
  58770. getClassName(): string;
  58771. /**
  58772. * Gets the value input component
  58773. */
  58774. get value(): NodeMaterialConnectionPoint;
  58775. /**
  58776. * Gets the output component
  58777. */
  58778. get output(): NodeMaterialConnectionPoint;
  58779. protected _buildBlock(state: NodeMaterialBuildState): this;
  58780. protected _dumpPropertiesCode(): string;
  58781. serialize(): any;
  58782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58783. }
  58784. }
  58785. declare module BABYLON {
  58786. /**
  58787. * Block used to apply a cross product between 2 vectors
  58788. */
  58789. export class CrossBlock extends NodeMaterialBlock {
  58790. /**
  58791. * Creates a new CrossBlock
  58792. * @param name defines the block name
  58793. */
  58794. constructor(name: string);
  58795. /**
  58796. * Gets the current class name
  58797. * @returns the class name
  58798. */
  58799. getClassName(): string;
  58800. /**
  58801. * Gets the left operand input component
  58802. */
  58803. get left(): NodeMaterialConnectionPoint;
  58804. /**
  58805. * Gets the right operand input component
  58806. */
  58807. get right(): NodeMaterialConnectionPoint;
  58808. /**
  58809. * Gets the output component
  58810. */
  58811. get output(): NodeMaterialConnectionPoint;
  58812. protected _buildBlock(state: NodeMaterialBuildState): this;
  58813. }
  58814. }
  58815. declare module BABYLON {
  58816. /**
  58817. * Block used to apply a dot product between 2 vectors
  58818. */
  58819. export class DotBlock extends NodeMaterialBlock {
  58820. /**
  58821. * Creates a new DotBlock
  58822. * @param name defines the block name
  58823. */
  58824. constructor(name: string);
  58825. /**
  58826. * Gets the current class name
  58827. * @returns the class name
  58828. */
  58829. getClassName(): string;
  58830. /**
  58831. * Gets the left operand input component
  58832. */
  58833. get left(): NodeMaterialConnectionPoint;
  58834. /**
  58835. * Gets the right operand input component
  58836. */
  58837. get right(): NodeMaterialConnectionPoint;
  58838. /**
  58839. * Gets the output component
  58840. */
  58841. get output(): NodeMaterialConnectionPoint;
  58842. protected _buildBlock(state: NodeMaterialBuildState): this;
  58843. }
  58844. }
  58845. declare module BABYLON {
  58846. /**
  58847. * Block used to remap a float from a range to a new one
  58848. */
  58849. export class RemapBlock extends NodeMaterialBlock {
  58850. /**
  58851. * Gets or sets the source range
  58852. */
  58853. sourceRange: Vector2;
  58854. /**
  58855. * Gets or sets the target range
  58856. */
  58857. targetRange: Vector2;
  58858. /**
  58859. * Creates a new RemapBlock
  58860. * @param name defines the block name
  58861. */
  58862. constructor(name: string);
  58863. /**
  58864. * Gets the current class name
  58865. * @returns the class name
  58866. */
  58867. getClassName(): string;
  58868. /**
  58869. * Gets the input component
  58870. */
  58871. get input(): NodeMaterialConnectionPoint;
  58872. /**
  58873. * Gets the source min input component
  58874. */
  58875. get sourceMin(): NodeMaterialConnectionPoint;
  58876. /**
  58877. * Gets the source max input component
  58878. */
  58879. get sourceMax(): NodeMaterialConnectionPoint;
  58880. /**
  58881. * Gets the target min input component
  58882. */
  58883. get targetMin(): NodeMaterialConnectionPoint;
  58884. /**
  58885. * Gets the target max input component
  58886. */
  58887. get targetMax(): NodeMaterialConnectionPoint;
  58888. /**
  58889. * Gets the output component
  58890. */
  58891. get output(): NodeMaterialConnectionPoint;
  58892. protected _buildBlock(state: NodeMaterialBuildState): this;
  58893. protected _dumpPropertiesCode(): string;
  58894. serialize(): any;
  58895. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58896. }
  58897. }
  58898. declare module BABYLON {
  58899. /**
  58900. * Block used to normalize a vector
  58901. */
  58902. export class NormalizeBlock extends NodeMaterialBlock {
  58903. /**
  58904. * Creates a new NormalizeBlock
  58905. * @param name defines the block name
  58906. */
  58907. constructor(name: string);
  58908. /**
  58909. * Gets the current class name
  58910. * @returns the class name
  58911. */
  58912. getClassName(): string;
  58913. /**
  58914. * Gets the input component
  58915. */
  58916. get input(): NodeMaterialConnectionPoint;
  58917. /**
  58918. * Gets the output component
  58919. */
  58920. get output(): NodeMaterialConnectionPoint;
  58921. protected _buildBlock(state: NodeMaterialBuildState): this;
  58922. }
  58923. }
  58924. declare module BABYLON {
  58925. /**
  58926. * Operations supported by the Trigonometry block
  58927. */
  58928. export enum TrigonometryBlockOperations {
  58929. /** Cos */
  58930. Cos = 0,
  58931. /** Sin */
  58932. Sin = 1,
  58933. /** Abs */
  58934. Abs = 2,
  58935. /** Exp */
  58936. Exp = 3,
  58937. /** Exp2 */
  58938. Exp2 = 4,
  58939. /** Round */
  58940. Round = 5,
  58941. /** Floor */
  58942. Floor = 6,
  58943. /** Ceiling */
  58944. Ceiling = 7,
  58945. /** Square root */
  58946. Sqrt = 8,
  58947. /** Log */
  58948. Log = 9,
  58949. /** Tangent */
  58950. Tan = 10,
  58951. /** Arc tangent */
  58952. ArcTan = 11,
  58953. /** Arc cosinus */
  58954. ArcCos = 12,
  58955. /** Arc sinus */
  58956. ArcSin = 13,
  58957. /** Fraction */
  58958. Fract = 14,
  58959. /** Sign */
  58960. Sign = 15,
  58961. /** To radians (from degrees) */
  58962. Radians = 16,
  58963. /** To degrees (from radians) */
  58964. Degrees = 17
  58965. }
  58966. /**
  58967. * Block used to apply trigonometry operation to floats
  58968. */
  58969. export class TrigonometryBlock extends NodeMaterialBlock {
  58970. /**
  58971. * Gets or sets the operation applied by the block
  58972. */
  58973. operation: TrigonometryBlockOperations;
  58974. /**
  58975. * Creates a new TrigonometryBlock
  58976. * @param name defines the block name
  58977. */
  58978. constructor(name: string);
  58979. /**
  58980. * Gets the current class name
  58981. * @returns the class name
  58982. */
  58983. getClassName(): string;
  58984. /**
  58985. * Gets the input component
  58986. */
  58987. get input(): NodeMaterialConnectionPoint;
  58988. /**
  58989. * Gets the output component
  58990. */
  58991. get output(): NodeMaterialConnectionPoint;
  58992. protected _buildBlock(state: NodeMaterialBuildState): this;
  58993. serialize(): any;
  58994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58995. protected _dumpPropertiesCode(): string;
  58996. }
  58997. }
  58998. declare module BABYLON {
  58999. /**
  59000. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59001. */
  59002. export class ColorMergerBlock extends NodeMaterialBlock {
  59003. /**
  59004. * Create a new ColorMergerBlock
  59005. * @param name defines the block name
  59006. */
  59007. constructor(name: string);
  59008. /**
  59009. * Gets the current class name
  59010. * @returns the class name
  59011. */
  59012. getClassName(): string;
  59013. /**
  59014. * Gets the rgb component (input)
  59015. */
  59016. get rgbIn(): NodeMaterialConnectionPoint;
  59017. /**
  59018. * Gets the r component (input)
  59019. */
  59020. get r(): NodeMaterialConnectionPoint;
  59021. /**
  59022. * Gets the g component (input)
  59023. */
  59024. get g(): NodeMaterialConnectionPoint;
  59025. /**
  59026. * Gets the b component (input)
  59027. */
  59028. get b(): NodeMaterialConnectionPoint;
  59029. /**
  59030. * Gets the a component (input)
  59031. */
  59032. get a(): NodeMaterialConnectionPoint;
  59033. /**
  59034. * Gets the rgba component (output)
  59035. */
  59036. get rgba(): NodeMaterialConnectionPoint;
  59037. /**
  59038. * Gets the rgb component (output)
  59039. */
  59040. get rgbOut(): NodeMaterialConnectionPoint;
  59041. /**
  59042. * Gets the rgb component (output)
  59043. * @deprecated Please use rgbOut instead.
  59044. */
  59045. get rgb(): NodeMaterialConnectionPoint;
  59046. protected _buildBlock(state: NodeMaterialBuildState): this;
  59047. }
  59048. }
  59049. declare module BABYLON {
  59050. /**
  59051. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59052. */
  59053. export class VectorMergerBlock extends NodeMaterialBlock {
  59054. /**
  59055. * Create a new VectorMergerBlock
  59056. * @param name defines the block name
  59057. */
  59058. constructor(name: string);
  59059. /**
  59060. * Gets the current class name
  59061. * @returns the class name
  59062. */
  59063. getClassName(): string;
  59064. /**
  59065. * Gets the xyz component (input)
  59066. */
  59067. get xyzIn(): NodeMaterialConnectionPoint;
  59068. /**
  59069. * Gets the xy component (input)
  59070. */
  59071. get xyIn(): NodeMaterialConnectionPoint;
  59072. /**
  59073. * Gets the x component (input)
  59074. */
  59075. get x(): NodeMaterialConnectionPoint;
  59076. /**
  59077. * Gets the y component (input)
  59078. */
  59079. get y(): NodeMaterialConnectionPoint;
  59080. /**
  59081. * Gets the z component (input)
  59082. */
  59083. get z(): NodeMaterialConnectionPoint;
  59084. /**
  59085. * Gets the w component (input)
  59086. */
  59087. get w(): NodeMaterialConnectionPoint;
  59088. /**
  59089. * Gets the xyzw component (output)
  59090. */
  59091. get xyzw(): NodeMaterialConnectionPoint;
  59092. /**
  59093. * Gets the xyz component (output)
  59094. */
  59095. get xyzOut(): NodeMaterialConnectionPoint;
  59096. /**
  59097. * Gets the xy component (output)
  59098. */
  59099. get xyOut(): NodeMaterialConnectionPoint;
  59100. /**
  59101. * Gets the xy component (output)
  59102. * @deprecated Please use xyOut instead.
  59103. */
  59104. get xy(): NodeMaterialConnectionPoint;
  59105. /**
  59106. * Gets the xyz component (output)
  59107. * @deprecated Please use xyzOut instead.
  59108. */
  59109. get xyz(): NodeMaterialConnectionPoint;
  59110. protected _buildBlock(state: NodeMaterialBuildState): this;
  59111. }
  59112. }
  59113. declare module BABYLON {
  59114. /**
  59115. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59116. */
  59117. export class ColorSplitterBlock extends NodeMaterialBlock {
  59118. /**
  59119. * Create a new ColorSplitterBlock
  59120. * @param name defines the block name
  59121. */
  59122. constructor(name: string);
  59123. /**
  59124. * Gets the current class name
  59125. * @returns the class name
  59126. */
  59127. getClassName(): string;
  59128. /**
  59129. * Gets the rgba component (input)
  59130. */
  59131. get rgba(): NodeMaterialConnectionPoint;
  59132. /**
  59133. * Gets the rgb component (input)
  59134. */
  59135. get rgbIn(): NodeMaterialConnectionPoint;
  59136. /**
  59137. * Gets the rgb component (output)
  59138. */
  59139. get rgbOut(): NodeMaterialConnectionPoint;
  59140. /**
  59141. * Gets the r component (output)
  59142. */
  59143. get r(): NodeMaterialConnectionPoint;
  59144. /**
  59145. * Gets the g component (output)
  59146. */
  59147. get g(): NodeMaterialConnectionPoint;
  59148. /**
  59149. * Gets the b component (output)
  59150. */
  59151. get b(): NodeMaterialConnectionPoint;
  59152. /**
  59153. * Gets the a component (output)
  59154. */
  59155. get a(): NodeMaterialConnectionPoint;
  59156. protected _inputRename(name: string): string;
  59157. protected _outputRename(name: string): string;
  59158. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59159. }
  59160. }
  59161. declare module BABYLON {
  59162. /**
  59163. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59164. */
  59165. export class VectorSplitterBlock extends NodeMaterialBlock {
  59166. /**
  59167. * Create a new VectorSplitterBlock
  59168. * @param name defines the block name
  59169. */
  59170. constructor(name: string);
  59171. /**
  59172. * Gets the current class name
  59173. * @returns the class name
  59174. */
  59175. getClassName(): string;
  59176. /**
  59177. * Gets the xyzw component (input)
  59178. */
  59179. get xyzw(): NodeMaterialConnectionPoint;
  59180. /**
  59181. * Gets the xyz component (input)
  59182. */
  59183. get xyzIn(): NodeMaterialConnectionPoint;
  59184. /**
  59185. * Gets the xy component (input)
  59186. */
  59187. get xyIn(): NodeMaterialConnectionPoint;
  59188. /**
  59189. * Gets the xyz component (output)
  59190. */
  59191. get xyzOut(): NodeMaterialConnectionPoint;
  59192. /**
  59193. * Gets the xy component (output)
  59194. */
  59195. get xyOut(): NodeMaterialConnectionPoint;
  59196. /**
  59197. * Gets the x component (output)
  59198. */
  59199. get x(): NodeMaterialConnectionPoint;
  59200. /**
  59201. * Gets the y component (output)
  59202. */
  59203. get y(): NodeMaterialConnectionPoint;
  59204. /**
  59205. * Gets the z component (output)
  59206. */
  59207. get z(): NodeMaterialConnectionPoint;
  59208. /**
  59209. * Gets the w component (output)
  59210. */
  59211. get w(): NodeMaterialConnectionPoint;
  59212. protected _inputRename(name: string): string;
  59213. protected _outputRename(name: string): string;
  59214. protected _buildBlock(state: NodeMaterialBuildState): this;
  59215. }
  59216. }
  59217. declare module BABYLON {
  59218. /**
  59219. * Block used to lerp between 2 values
  59220. */
  59221. export class LerpBlock extends NodeMaterialBlock {
  59222. /**
  59223. * Creates a new LerpBlock
  59224. * @param name defines the block name
  59225. */
  59226. constructor(name: string);
  59227. /**
  59228. * Gets the current class name
  59229. * @returns the class name
  59230. */
  59231. getClassName(): string;
  59232. /**
  59233. * Gets the left operand input component
  59234. */
  59235. get left(): NodeMaterialConnectionPoint;
  59236. /**
  59237. * Gets the right operand input component
  59238. */
  59239. get right(): NodeMaterialConnectionPoint;
  59240. /**
  59241. * Gets the gradient operand input component
  59242. */
  59243. get gradient(): NodeMaterialConnectionPoint;
  59244. /**
  59245. * Gets the output component
  59246. */
  59247. get output(): NodeMaterialConnectionPoint;
  59248. protected _buildBlock(state: NodeMaterialBuildState): this;
  59249. }
  59250. }
  59251. declare module BABYLON {
  59252. /**
  59253. * Block used to divide 2 vectors
  59254. */
  59255. export class DivideBlock extends NodeMaterialBlock {
  59256. /**
  59257. * Creates a new DivideBlock
  59258. * @param name defines the block name
  59259. */
  59260. constructor(name: string);
  59261. /**
  59262. * Gets the current class name
  59263. * @returns the class name
  59264. */
  59265. getClassName(): string;
  59266. /**
  59267. * Gets the left operand input component
  59268. */
  59269. get left(): NodeMaterialConnectionPoint;
  59270. /**
  59271. * Gets the right operand input component
  59272. */
  59273. get right(): NodeMaterialConnectionPoint;
  59274. /**
  59275. * Gets the output component
  59276. */
  59277. get output(): NodeMaterialConnectionPoint;
  59278. protected _buildBlock(state: NodeMaterialBuildState): this;
  59279. }
  59280. }
  59281. declare module BABYLON {
  59282. /**
  59283. * Block used to subtract 2 vectors
  59284. */
  59285. export class SubtractBlock extends NodeMaterialBlock {
  59286. /**
  59287. * Creates a new SubtractBlock
  59288. * @param name defines the block name
  59289. */
  59290. constructor(name: string);
  59291. /**
  59292. * Gets the current class name
  59293. * @returns the class name
  59294. */
  59295. getClassName(): string;
  59296. /**
  59297. * Gets the left operand input component
  59298. */
  59299. get left(): NodeMaterialConnectionPoint;
  59300. /**
  59301. * Gets the right operand input component
  59302. */
  59303. get right(): NodeMaterialConnectionPoint;
  59304. /**
  59305. * Gets the output component
  59306. */
  59307. get output(): NodeMaterialConnectionPoint;
  59308. protected _buildBlock(state: NodeMaterialBuildState): this;
  59309. }
  59310. }
  59311. declare module BABYLON {
  59312. /**
  59313. * Block used to step a value
  59314. */
  59315. export class StepBlock extends NodeMaterialBlock {
  59316. /**
  59317. * Creates a new StepBlock
  59318. * @param name defines the block name
  59319. */
  59320. constructor(name: string);
  59321. /**
  59322. * Gets the current class name
  59323. * @returns the class name
  59324. */
  59325. getClassName(): string;
  59326. /**
  59327. * Gets the value operand input component
  59328. */
  59329. get value(): NodeMaterialConnectionPoint;
  59330. /**
  59331. * Gets the edge operand input component
  59332. */
  59333. get edge(): NodeMaterialConnectionPoint;
  59334. /**
  59335. * Gets the output component
  59336. */
  59337. get output(): NodeMaterialConnectionPoint;
  59338. protected _buildBlock(state: NodeMaterialBuildState): this;
  59339. }
  59340. }
  59341. declare module BABYLON {
  59342. /**
  59343. * Block used to get the opposite (1 - x) of a value
  59344. */
  59345. export class OneMinusBlock extends NodeMaterialBlock {
  59346. /**
  59347. * Creates a new OneMinusBlock
  59348. * @param name defines the block name
  59349. */
  59350. constructor(name: string);
  59351. /**
  59352. * Gets the current class name
  59353. * @returns the class name
  59354. */
  59355. getClassName(): string;
  59356. /**
  59357. * Gets the input component
  59358. */
  59359. get input(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the output component
  59362. */
  59363. get output(): NodeMaterialConnectionPoint;
  59364. protected _buildBlock(state: NodeMaterialBuildState): this;
  59365. }
  59366. }
  59367. declare module BABYLON {
  59368. /**
  59369. * Block used to get the view direction
  59370. */
  59371. export class ViewDirectionBlock extends NodeMaterialBlock {
  59372. /**
  59373. * Creates a new ViewDirectionBlock
  59374. * @param name defines the block name
  59375. */
  59376. constructor(name: string);
  59377. /**
  59378. * Gets the current class name
  59379. * @returns the class name
  59380. */
  59381. getClassName(): string;
  59382. /**
  59383. * Gets the world position component
  59384. */
  59385. get worldPosition(): NodeMaterialConnectionPoint;
  59386. /**
  59387. * Gets the camera position component
  59388. */
  59389. get cameraPosition(): NodeMaterialConnectionPoint;
  59390. /**
  59391. * Gets the output component
  59392. */
  59393. get output(): NodeMaterialConnectionPoint;
  59394. autoConfigure(material: NodeMaterial): void;
  59395. protected _buildBlock(state: NodeMaterialBuildState): this;
  59396. }
  59397. }
  59398. declare module BABYLON {
  59399. /**
  59400. * Block used to compute fresnel value
  59401. */
  59402. export class FresnelBlock extends NodeMaterialBlock {
  59403. /**
  59404. * Create a new FresnelBlock
  59405. * @param name defines the block name
  59406. */
  59407. constructor(name: string);
  59408. /**
  59409. * Gets the current class name
  59410. * @returns the class name
  59411. */
  59412. getClassName(): string;
  59413. /**
  59414. * Gets the world normal input component
  59415. */
  59416. get worldNormal(): NodeMaterialConnectionPoint;
  59417. /**
  59418. * Gets the view direction input component
  59419. */
  59420. get viewDirection(): NodeMaterialConnectionPoint;
  59421. /**
  59422. * Gets the bias input component
  59423. */
  59424. get bias(): NodeMaterialConnectionPoint;
  59425. /**
  59426. * Gets the camera (or eye) position component
  59427. */
  59428. get power(): NodeMaterialConnectionPoint;
  59429. /**
  59430. * Gets the fresnel output component
  59431. */
  59432. get fresnel(): NodeMaterialConnectionPoint;
  59433. autoConfigure(material: NodeMaterial): void;
  59434. protected _buildBlock(state: NodeMaterialBuildState): this;
  59435. }
  59436. }
  59437. declare module BABYLON {
  59438. /**
  59439. * Block used to get the max of 2 values
  59440. */
  59441. export class MaxBlock extends NodeMaterialBlock {
  59442. /**
  59443. * Creates a new MaxBlock
  59444. * @param name defines the block name
  59445. */
  59446. constructor(name: string);
  59447. /**
  59448. * Gets the current class name
  59449. * @returns the class name
  59450. */
  59451. getClassName(): string;
  59452. /**
  59453. * Gets the left operand input component
  59454. */
  59455. get left(): NodeMaterialConnectionPoint;
  59456. /**
  59457. * Gets the right operand input component
  59458. */
  59459. get right(): NodeMaterialConnectionPoint;
  59460. /**
  59461. * Gets the output component
  59462. */
  59463. get output(): NodeMaterialConnectionPoint;
  59464. protected _buildBlock(state: NodeMaterialBuildState): this;
  59465. }
  59466. }
  59467. declare module BABYLON {
  59468. /**
  59469. * Block used to get the min of 2 values
  59470. */
  59471. export class MinBlock extends NodeMaterialBlock {
  59472. /**
  59473. * Creates a new MinBlock
  59474. * @param name defines the block name
  59475. */
  59476. constructor(name: string);
  59477. /**
  59478. * Gets the current class name
  59479. * @returns the class name
  59480. */
  59481. getClassName(): string;
  59482. /**
  59483. * Gets the left operand input component
  59484. */
  59485. get left(): NodeMaterialConnectionPoint;
  59486. /**
  59487. * Gets the right operand input component
  59488. */
  59489. get right(): NodeMaterialConnectionPoint;
  59490. /**
  59491. * Gets the output component
  59492. */
  59493. get output(): NodeMaterialConnectionPoint;
  59494. protected _buildBlock(state: NodeMaterialBuildState): this;
  59495. }
  59496. }
  59497. declare module BABYLON {
  59498. /**
  59499. * Block used to get the distance between 2 values
  59500. */
  59501. export class DistanceBlock extends NodeMaterialBlock {
  59502. /**
  59503. * Creates a new DistanceBlock
  59504. * @param name defines the block name
  59505. */
  59506. constructor(name: string);
  59507. /**
  59508. * Gets the current class name
  59509. * @returns the class name
  59510. */
  59511. getClassName(): string;
  59512. /**
  59513. * Gets the left operand input component
  59514. */
  59515. get left(): NodeMaterialConnectionPoint;
  59516. /**
  59517. * Gets the right operand input component
  59518. */
  59519. get right(): NodeMaterialConnectionPoint;
  59520. /**
  59521. * Gets the output component
  59522. */
  59523. get output(): NodeMaterialConnectionPoint;
  59524. protected _buildBlock(state: NodeMaterialBuildState): this;
  59525. }
  59526. }
  59527. declare module BABYLON {
  59528. /**
  59529. * Block used to get the length of a vector
  59530. */
  59531. export class LengthBlock extends NodeMaterialBlock {
  59532. /**
  59533. * Creates a new LengthBlock
  59534. * @param name defines the block name
  59535. */
  59536. constructor(name: string);
  59537. /**
  59538. * Gets the current class name
  59539. * @returns the class name
  59540. */
  59541. getClassName(): string;
  59542. /**
  59543. * Gets the value input component
  59544. */
  59545. get value(): NodeMaterialConnectionPoint;
  59546. /**
  59547. * Gets the output component
  59548. */
  59549. get output(): NodeMaterialConnectionPoint;
  59550. protected _buildBlock(state: NodeMaterialBuildState): this;
  59551. }
  59552. }
  59553. declare module BABYLON {
  59554. /**
  59555. * Block used to get negative version of a value (i.e. x * -1)
  59556. */
  59557. export class NegateBlock extends NodeMaterialBlock {
  59558. /**
  59559. * Creates a new NegateBlock
  59560. * @param name defines the block name
  59561. */
  59562. constructor(name: string);
  59563. /**
  59564. * Gets the current class name
  59565. * @returns the class name
  59566. */
  59567. getClassName(): string;
  59568. /**
  59569. * Gets the value input component
  59570. */
  59571. get value(): NodeMaterialConnectionPoint;
  59572. /**
  59573. * Gets the output component
  59574. */
  59575. get output(): NodeMaterialConnectionPoint;
  59576. protected _buildBlock(state: NodeMaterialBuildState): this;
  59577. }
  59578. }
  59579. declare module BABYLON {
  59580. /**
  59581. * Block used to get the value of the first parameter raised to the power of the second
  59582. */
  59583. export class PowBlock extends NodeMaterialBlock {
  59584. /**
  59585. * Creates a new PowBlock
  59586. * @param name defines the block name
  59587. */
  59588. constructor(name: string);
  59589. /**
  59590. * Gets the current class name
  59591. * @returns the class name
  59592. */
  59593. getClassName(): string;
  59594. /**
  59595. * Gets the value operand input component
  59596. */
  59597. get value(): NodeMaterialConnectionPoint;
  59598. /**
  59599. * Gets the power operand input component
  59600. */
  59601. get power(): NodeMaterialConnectionPoint;
  59602. /**
  59603. * Gets the output component
  59604. */
  59605. get output(): NodeMaterialConnectionPoint;
  59606. protected _buildBlock(state: NodeMaterialBuildState): this;
  59607. }
  59608. }
  59609. declare module BABYLON {
  59610. /**
  59611. * Block used to get a random number
  59612. */
  59613. export class RandomNumberBlock extends NodeMaterialBlock {
  59614. /**
  59615. * Creates a new RandomNumberBlock
  59616. * @param name defines the block name
  59617. */
  59618. constructor(name: string);
  59619. /**
  59620. * Gets the current class name
  59621. * @returns the class name
  59622. */
  59623. getClassName(): string;
  59624. /**
  59625. * Gets the seed input component
  59626. */
  59627. get seed(): NodeMaterialConnectionPoint;
  59628. /**
  59629. * Gets the output component
  59630. */
  59631. get output(): NodeMaterialConnectionPoint;
  59632. protected _buildBlock(state: NodeMaterialBuildState): this;
  59633. }
  59634. }
  59635. declare module BABYLON {
  59636. /**
  59637. * Block used to compute arc tangent of 2 values
  59638. */
  59639. export class ArcTan2Block extends NodeMaterialBlock {
  59640. /**
  59641. * Creates a new ArcTan2Block
  59642. * @param name defines the block name
  59643. */
  59644. constructor(name: string);
  59645. /**
  59646. * Gets the current class name
  59647. * @returns the class name
  59648. */
  59649. getClassName(): string;
  59650. /**
  59651. * Gets the x operand input component
  59652. */
  59653. get x(): NodeMaterialConnectionPoint;
  59654. /**
  59655. * Gets the y operand input component
  59656. */
  59657. get y(): NodeMaterialConnectionPoint;
  59658. /**
  59659. * Gets the output component
  59660. */
  59661. get output(): NodeMaterialConnectionPoint;
  59662. protected _buildBlock(state: NodeMaterialBuildState): this;
  59663. }
  59664. }
  59665. declare module BABYLON {
  59666. /**
  59667. * Block used to smooth step a value
  59668. */
  59669. export class SmoothStepBlock extends NodeMaterialBlock {
  59670. /**
  59671. * Creates a new SmoothStepBlock
  59672. * @param name defines the block name
  59673. */
  59674. constructor(name: string);
  59675. /**
  59676. * Gets the current class name
  59677. * @returns the class name
  59678. */
  59679. getClassName(): string;
  59680. /**
  59681. * Gets the value operand input component
  59682. */
  59683. get value(): NodeMaterialConnectionPoint;
  59684. /**
  59685. * Gets the first edge operand input component
  59686. */
  59687. get edge0(): NodeMaterialConnectionPoint;
  59688. /**
  59689. * Gets the second edge operand input component
  59690. */
  59691. get edge1(): NodeMaterialConnectionPoint;
  59692. /**
  59693. * Gets the output component
  59694. */
  59695. get output(): NodeMaterialConnectionPoint;
  59696. protected _buildBlock(state: NodeMaterialBuildState): this;
  59697. }
  59698. }
  59699. declare module BABYLON {
  59700. /**
  59701. * Block used to get the reciprocal (1 / x) of a value
  59702. */
  59703. export class ReciprocalBlock extends NodeMaterialBlock {
  59704. /**
  59705. * Creates a new ReciprocalBlock
  59706. * @param name defines the block name
  59707. */
  59708. constructor(name: string);
  59709. /**
  59710. * Gets the current class name
  59711. * @returns the class name
  59712. */
  59713. getClassName(): string;
  59714. /**
  59715. * Gets the input component
  59716. */
  59717. get input(): NodeMaterialConnectionPoint;
  59718. /**
  59719. * Gets the output component
  59720. */
  59721. get output(): NodeMaterialConnectionPoint;
  59722. protected _buildBlock(state: NodeMaterialBuildState): this;
  59723. }
  59724. }
  59725. declare module BABYLON {
  59726. /**
  59727. * Block used to replace a color by another one
  59728. */
  59729. export class ReplaceColorBlock extends NodeMaterialBlock {
  59730. /**
  59731. * Creates a new ReplaceColorBlock
  59732. * @param name defines the block name
  59733. */
  59734. constructor(name: string);
  59735. /**
  59736. * Gets the current class name
  59737. * @returns the class name
  59738. */
  59739. getClassName(): string;
  59740. /**
  59741. * Gets the value input component
  59742. */
  59743. get value(): NodeMaterialConnectionPoint;
  59744. /**
  59745. * Gets the reference input component
  59746. */
  59747. get reference(): NodeMaterialConnectionPoint;
  59748. /**
  59749. * Gets the distance input component
  59750. */
  59751. get distance(): NodeMaterialConnectionPoint;
  59752. /**
  59753. * Gets the replacement input component
  59754. */
  59755. get replacement(): NodeMaterialConnectionPoint;
  59756. /**
  59757. * Gets the output component
  59758. */
  59759. get output(): NodeMaterialConnectionPoint;
  59760. protected _buildBlock(state: NodeMaterialBuildState): this;
  59761. }
  59762. }
  59763. declare module BABYLON {
  59764. /**
  59765. * Block used to posterize a value
  59766. * @see https://en.wikipedia.org/wiki/Posterization
  59767. */
  59768. export class PosterizeBlock extends NodeMaterialBlock {
  59769. /**
  59770. * Creates a new PosterizeBlock
  59771. * @param name defines the block name
  59772. */
  59773. constructor(name: string);
  59774. /**
  59775. * Gets the current class name
  59776. * @returns the class name
  59777. */
  59778. getClassName(): string;
  59779. /**
  59780. * Gets the value input component
  59781. */
  59782. get value(): NodeMaterialConnectionPoint;
  59783. /**
  59784. * Gets the steps input component
  59785. */
  59786. get steps(): NodeMaterialConnectionPoint;
  59787. /**
  59788. * Gets the output component
  59789. */
  59790. get output(): NodeMaterialConnectionPoint;
  59791. protected _buildBlock(state: NodeMaterialBuildState): this;
  59792. }
  59793. }
  59794. declare module BABYLON {
  59795. /**
  59796. * Operations supported by the Wave block
  59797. */
  59798. export enum WaveBlockKind {
  59799. /** SawTooth */
  59800. SawTooth = 0,
  59801. /** Square */
  59802. Square = 1,
  59803. /** Triangle */
  59804. Triangle = 2
  59805. }
  59806. /**
  59807. * Block used to apply wave operation to floats
  59808. */
  59809. export class WaveBlock extends NodeMaterialBlock {
  59810. /**
  59811. * Gets or sets the kibnd of wave to be applied by the block
  59812. */
  59813. kind: WaveBlockKind;
  59814. /**
  59815. * Creates a new WaveBlock
  59816. * @param name defines the block name
  59817. */
  59818. constructor(name: string);
  59819. /**
  59820. * Gets the current class name
  59821. * @returns the class name
  59822. */
  59823. getClassName(): string;
  59824. /**
  59825. * Gets the input component
  59826. */
  59827. get input(): NodeMaterialConnectionPoint;
  59828. /**
  59829. * Gets the output component
  59830. */
  59831. get output(): NodeMaterialConnectionPoint;
  59832. protected _buildBlock(state: NodeMaterialBuildState): this;
  59833. serialize(): any;
  59834. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59835. }
  59836. }
  59837. declare module BABYLON {
  59838. /**
  59839. * Class used to store a color step for the GradientBlock
  59840. */
  59841. export class GradientBlockColorStep {
  59842. /**
  59843. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59844. */
  59845. step: number;
  59846. /**
  59847. * Gets or sets the color associated with this step
  59848. */
  59849. color: Color3;
  59850. /**
  59851. * Creates a new GradientBlockColorStep
  59852. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59853. * @param color defines the color associated with this step
  59854. */
  59855. constructor(
  59856. /**
  59857. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59858. */
  59859. step: number,
  59860. /**
  59861. * Gets or sets the color associated with this step
  59862. */
  59863. color: Color3);
  59864. }
  59865. /**
  59866. * Block used to return a color from a gradient based on an input value between 0 and 1
  59867. */
  59868. export class GradientBlock extends NodeMaterialBlock {
  59869. /**
  59870. * Gets or sets the list of color steps
  59871. */
  59872. colorSteps: GradientBlockColorStep[];
  59873. /**
  59874. * Creates a new GradientBlock
  59875. * @param name defines the block name
  59876. */
  59877. constructor(name: string);
  59878. /**
  59879. * Gets the current class name
  59880. * @returns the class name
  59881. */
  59882. getClassName(): string;
  59883. /**
  59884. * Gets the gradient input component
  59885. */
  59886. get gradient(): NodeMaterialConnectionPoint;
  59887. /**
  59888. * Gets the output component
  59889. */
  59890. get output(): NodeMaterialConnectionPoint;
  59891. private _writeColorConstant;
  59892. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59893. serialize(): any;
  59894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59895. protected _dumpPropertiesCode(): string;
  59896. }
  59897. }
  59898. declare module BABYLON {
  59899. /**
  59900. * Block used to normalize lerp between 2 values
  59901. */
  59902. export class NLerpBlock extends NodeMaterialBlock {
  59903. /**
  59904. * Creates a new NLerpBlock
  59905. * @param name defines the block name
  59906. */
  59907. constructor(name: string);
  59908. /**
  59909. * Gets the current class name
  59910. * @returns the class name
  59911. */
  59912. getClassName(): string;
  59913. /**
  59914. * Gets the left operand input component
  59915. */
  59916. get left(): NodeMaterialConnectionPoint;
  59917. /**
  59918. * Gets the right operand input component
  59919. */
  59920. get right(): NodeMaterialConnectionPoint;
  59921. /**
  59922. * Gets the gradient operand input component
  59923. */
  59924. get gradient(): NodeMaterialConnectionPoint;
  59925. /**
  59926. * Gets the output component
  59927. */
  59928. get output(): NodeMaterialConnectionPoint;
  59929. protected _buildBlock(state: NodeMaterialBuildState): this;
  59930. }
  59931. }
  59932. declare module BABYLON {
  59933. /**
  59934. * block used to Generate a Worley Noise 3D Noise Pattern
  59935. */
  59936. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59937. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59938. manhattanDistance: boolean;
  59939. /**
  59940. * Creates a new WorleyNoise3DBlock
  59941. * @param name defines the block name
  59942. */
  59943. constructor(name: string);
  59944. /**
  59945. * Gets the current class name
  59946. * @returns the class name
  59947. */
  59948. getClassName(): string;
  59949. /**
  59950. * Gets the seed input component
  59951. */
  59952. get seed(): NodeMaterialConnectionPoint;
  59953. /**
  59954. * Gets the jitter input component
  59955. */
  59956. get jitter(): NodeMaterialConnectionPoint;
  59957. /**
  59958. * Gets the output component
  59959. */
  59960. get output(): NodeMaterialConnectionPoint;
  59961. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59962. /**
  59963. * Exposes the properties to the UI?
  59964. */
  59965. protected _dumpPropertiesCode(): string;
  59966. /**
  59967. * Exposes the properties to the Seralize?
  59968. */
  59969. serialize(): any;
  59970. /**
  59971. * Exposes the properties to the deseralize?
  59972. */
  59973. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59974. }
  59975. }
  59976. declare module BABYLON {
  59977. /**
  59978. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59979. */
  59980. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59981. /**
  59982. * Creates a new SimplexPerlin3DBlock
  59983. * @param name defines the block name
  59984. */
  59985. constructor(name: string);
  59986. /**
  59987. * Gets the current class name
  59988. * @returns the class name
  59989. */
  59990. getClassName(): string;
  59991. /**
  59992. * Gets the seed operand input component
  59993. */
  59994. get seed(): NodeMaterialConnectionPoint;
  59995. /**
  59996. * Gets the output component
  59997. */
  59998. get output(): NodeMaterialConnectionPoint;
  59999. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60000. }
  60001. }
  60002. declare module BABYLON {
  60003. /**
  60004. * Block used to blend normals
  60005. */
  60006. export class NormalBlendBlock extends NodeMaterialBlock {
  60007. /**
  60008. * Creates a new NormalBlendBlock
  60009. * @param name defines the block name
  60010. */
  60011. constructor(name: string);
  60012. /**
  60013. * Gets the current class name
  60014. * @returns the class name
  60015. */
  60016. getClassName(): string;
  60017. /**
  60018. * Gets the first input component
  60019. */
  60020. get normalMap0(): NodeMaterialConnectionPoint;
  60021. /**
  60022. * Gets the second input component
  60023. */
  60024. get normalMap1(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the output component
  60027. */
  60028. get output(): NodeMaterialConnectionPoint;
  60029. protected _buildBlock(state: NodeMaterialBuildState): this;
  60030. }
  60031. }
  60032. declare module BABYLON {
  60033. /**
  60034. * Block used to rotate a 2d vector by a given angle
  60035. */
  60036. export class Rotate2dBlock extends NodeMaterialBlock {
  60037. /**
  60038. * Creates a new Rotate2dBlock
  60039. * @param name defines the block name
  60040. */
  60041. constructor(name: string);
  60042. /**
  60043. * Gets the current class name
  60044. * @returns the class name
  60045. */
  60046. getClassName(): string;
  60047. /**
  60048. * Gets the input vector
  60049. */
  60050. get input(): NodeMaterialConnectionPoint;
  60051. /**
  60052. * Gets the input angle
  60053. */
  60054. get angle(): NodeMaterialConnectionPoint;
  60055. /**
  60056. * Gets the output component
  60057. */
  60058. get output(): NodeMaterialConnectionPoint;
  60059. autoConfigure(material: NodeMaterial): void;
  60060. protected _buildBlock(state: NodeMaterialBuildState): this;
  60061. }
  60062. }
  60063. declare module BABYLON {
  60064. /**
  60065. * Block used to get the reflected vector from a direction and a normal
  60066. */
  60067. export class ReflectBlock extends NodeMaterialBlock {
  60068. /**
  60069. * Creates a new ReflectBlock
  60070. * @param name defines the block name
  60071. */
  60072. constructor(name: string);
  60073. /**
  60074. * Gets the current class name
  60075. * @returns the class name
  60076. */
  60077. getClassName(): string;
  60078. /**
  60079. * Gets the incident component
  60080. */
  60081. get incident(): NodeMaterialConnectionPoint;
  60082. /**
  60083. * Gets the normal component
  60084. */
  60085. get normal(): NodeMaterialConnectionPoint;
  60086. /**
  60087. * Gets the output component
  60088. */
  60089. get output(): NodeMaterialConnectionPoint;
  60090. protected _buildBlock(state: NodeMaterialBuildState): this;
  60091. }
  60092. }
  60093. declare module BABYLON {
  60094. /**
  60095. * Block used to get the refracted vector from a direction and a normal
  60096. */
  60097. export class RefractBlock extends NodeMaterialBlock {
  60098. /**
  60099. * Creates a new RefractBlock
  60100. * @param name defines the block name
  60101. */
  60102. constructor(name: string);
  60103. /**
  60104. * Gets the current class name
  60105. * @returns the class name
  60106. */
  60107. getClassName(): string;
  60108. /**
  60109. * Gets the incident component
  60110. */
  60111. get incident(): NodeMaterialConnectionPoint;
  60112. /**
  60113. * Gets the normal component
  60114. */
  60115. get normal(): NodeMaterialConnectionPoint;
  60116. /**
  60117. * Gets the index of refraction component
  60118. */
  60119. get ior(): NodeMaterialConnectionPoint;
  60120. /**
  60121. * Gets the output component
  60122. */
  60123. get output(): NodeMaterialConnectionPoint;
  60124. protected _buildBlock(state: NodeMaterialBuildState): this;
  60125. }
  60126. }
  60127. declare module BABYLON {
  60128. /**
  60129. * Block used to desaturate a color
  60130. */
  60131. export class DesaturateBlock extends NodeMaterialBlock {
  60132. /**
  60133. * Creates a new DesaturateBlock
  60134. * @param name defines the block name
  60135. */
  60136. constructor(name: string);
  60137. /**
  60138. * Gets the current class name
  60139. * @returns the class name
  60140. */
  60141. getClassName(): string;
  60142. /**
  60143. * Gets the color operand input component
  60144. */
  60145. get color(): NodeMaterialConnectionPoint;
  60146. /**
  60147. * Gets the level operand input component
  60148. */
  60149. get level(): NodeMaterialConnectionPoint;
  60150. /**
  60151. * Gets the output component
  60152. */
  60153. get output(): NodeMaterialConnectionPoint;
  60154. protected _buildBlock(state: NodeMaterialBuildState): this;
  60155. }
  60156. }
  60157. declare module BABYLON {
  60158. /**
  60159. * Effect Render Options
  60160. */
  60161. export interface IEffectRendererOptions {
  60162. /**
  60163. * Defines the vertices positions.
  60164. */
  60165. positions?: number[];
  60166. /**
  60167. * Defines the indices.
  60168. */
  60169. indices?: number[];
  60170. }
  60171. /**
  60172. * Helper class to render one or more effects
  60173. */
  60174. export class EffectRenderer {
  60175. private engine;
  60176. private static _DefaultOptions;
  60177. private _vertexBuffers;
  60178. private _indexBuffer;
  60179. private _ringBufferIndex;
  60180. private _ringScreenBuffer;
  60181. private _fullscreenViewport;
  60182. private _getNextFrameBuffer;
  60183. /**
  60184. * Creates an effect renderer
  60185. * @param engine the engine to use for rendering
  60186. * @param options defines the options of the effect renderer
  60187. */
  60188. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60189. /**
  60190. * Sets the current viewport in normalized coordinates 0-1
  60191. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60192. */
  60193. setViewport(viewport?: Viewport): void;
  60194. /**
  60195. * Binds the embedded attributes buffer to the effect.
  60196. * @param effect Defines the effect to bind the attributes for
  60197. */
  60198. bindBuffers(effect: Effect): void;
  60199. /**
  60200. * Sets the current effect wrapper to use during draw.
  60201. * The effect needs to be ready before calling this api.
  60202. * This also sets the default full screen position attribute.
  60203. * @param effectWrapper Defines the effect to draw with
  60204. */
  60205. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60206. /**
  60207. * Draws a full screen quad.
  60208. */
  60209. draw(): void;
  60210. /**
  60211. * renders one or more effects to a specified texture
  60212. * @param effectWrappers list of effects to renderer
  60213. * @param outputTexture texture to draw to, if null it will render to the screen
  60214. */
  60215. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60216. /**
  60217. * Disposes of the effect renderer
  60218. */
  60219. dispose(): void;
  60220. }
  60221. /**
  60222. * Options to create an EffectWrapper
  60223. */
  60224. interface EffectWrapperCreationOptions {
  60225. /**
  60226. * Engine to use to create the effect
  60227. */
  60228. engine: ThinEngine;
  60229. /**
  60230. * Fragment shader for the effect
  60231. */
  60232. fragmentShader: string;
  60233. /**
  60234. * Vertex shader for the effect
  60235. */
  60236. vertexShader?: string;
  60237. /**
  60238. * Attributes to use in the shader
  60239. */
  60240. attributeNames?: Array<string>;
  60241. /**
  60242. * Uniforms to use in the shader
  60243. */
  60244. uniformNames?: Array<string>;
  60245. /**
  60246. * Texture sampler names to use in the shader
  60247. */
  60248. samplerNames?: Array<string>;
  60249. /**
  60250. * The friendly name of the effect displayed in Spector.
  60251. */
  60252. name?: string;
  60253. }
  60254. /**
  60255. * Wraps an effect to be used for rendering
  60256. */
  60257. export class EffectWrapper {
  60258. /**
  60259. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60260. */
  60261. onApplyObservable: Observable<{}>;
  60262. /**
  60263. * The underlying effect
  60264. */
  60265. effect: Effect;
  60266. /**
  60267. * Creates an effect to be renderer
  60268. * @param creationOptions options to create the effect
  60269. */
  60270. constructor(creationOptions: EffectWrapperCreationOptions);
  60271. /**
  60272. * Disposes of the effect wrapper
  60273. */
  60274. dispose(): void;
  60275. }
  60276. }
  60277. declare module BABYLON {
  60278. /**
  60279. * Helper class to push actions to a pool of workers.
  60280. */
  60281. export class WorkerPool implements IDisposable {
  60282. private _workerInfos;
  60283. private _pendingActions;
  60284. /**
  60285. * Constructor
  60286. * @param workers Array of workers to use for actions
  60287. */
  60288. constructor(workers: Array<Worker>);
  60289. /**
  60290. * Terminates all workers and clears any pending actions.
  60291. */
  60292. dispose(): void;
  60293. /**
  60294. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60295. * pended until a worker has completed its action.
  60296. * @param action The action to perform. Call onComplete when the action is complete.
  60297. */
  60298. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60299. private _execute;
  60300. }
  60301. }
  60302. declare module BABYLON {
  60303. /**
  60304. * Configuration for Draco compression
  60305. */
  60306. export interface IDracoCompressionConfiguration {
  60307. /**
  60308. * Configuration for the decoder.
  60309. */
  60310. decoder: {
  60311. /**
  60312. * The url to the WebAssembly module.
  60313. */
  60314. wasmUrl?: string;
  60315. /**
  60316. * The url to the WebAssembly binary.
  60317. */
  60318. wasmBinaryUrl?: string;
  60319. /**
  60320. * The url to the fallback JavaScript module.
  60321. */
  60322. fallbackUrl?: string;
  60323. };
  60324. }
  60325. /**
  60326. * Draco compression (https://google.github.io/draco/)
  60327. *
  60328. * This class wraps the Draco module.
  60329. *
  60330. * **Encoder**
  60331. *
  60332. * The encoder is not currently implemented.
  60333. *
  60334. * **Decoder**
  60335. *
  60336. * 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.
  60337. *
  60338. * To update the configuration, use the following code:
  60339. * ```javascript
  60340. * DracoCompression.Configuration = {
  60341. * decoder: {
  60342. * wasmUrl: "<url to the WebAssembly library>",
  60343. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60344. * fallbackUrl: "<url to the fallback JavaScript library>",
  60345. * }
  60346. * };
  60347. * ```
  60348. *
  60349. * 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.
  60350. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60351. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60352. *
  60353. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60354. * ```javascript
  60355. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60356. * ```
  60357. *
  60358. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60359. */
  60360. export class DracoCompression implements IDisposable {
  60361. private _workerPoolPromise?;
  60362. private _decoderModulePromise?;
  60363. /**
  60364. * The configuration. Defaults to the following urls:
  60365. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60366. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60367. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60368. */
  60369. static Configuration: IDracoCompressionConfiguration;
  60370. /**
  60371. * Returns true if the decoder configuration is available.
  60372. */
  60373. static get DecoderAvailable(): boolean;
  60374. /**
  60375. * Default number of workers to create when creating the draco compression object.
  60376. */
  60377. static DefaultNumWorkers: number;
  60378. private static GetDefaultNumWorkers;
  60379. private static _Default;
  60380. /**
  60381. * Default instance for the draco compression object.
  60382. */
  60383. static get Default(): DracoCompression;
  60384. /**
  60385. * Constructor
  60386. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60387. */
  60388. constructor(numWorkers?: number);
  60389. /**
  60390. * Stop all async operations and release resources.
  60391. */
  60392. dispose(): void;
  60393. /**
  60394. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60395. * @returns a promise that resolves when ready
  60396. */
  60397. whenReadyAsync(): Promise<void>;
  60398. /**
  60399. * Decode Draco compressed mesh data to vertex data.
  60400. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60401. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60402. * @returns A promise that resolves with the decoded vertex data
  60403. */
  60404. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60405. [kind: string]: number;
  60406. }): Promise<VertexData>;
  60407. }
  60408. }
  60409. declare module BABYLON {
  60410. /**
  60411. * Class for building Constructive Solid Geometry
  60412. */
  60413. export class CSG {
  60414. private polygons;
  60415. /**
  60416. * The world matrix
  60417. */
  60418. matrix: Matrix;
  60419. /**
  60420. * Stores the position
  60421. */
  60422. position: Vector3;
  60423. /**
  60424. * Stores the rotation
  60425. */
  60426. rotation: Vector3;
  60427. /**
  60428. * Stores the rotation quaternion
  60429. */
  60430. rotationQuaternion: Nullable<Quaternion>;
  60431. /**
  60432. * Stores the scaling vector
  60433. */
  60434. scaling: Vector3;
  60435. /**
  60436. * Convert the Mesh to CSG
  60437. * @param mesh The Mesh to convert to CSG
  60438. * @returns A new CSG from the Mesh
  60439. */
  60440. static FromMesh(mesh: Mesh): CSG;
  60441. /**
  60442. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60443. * @param polygons Polygons used to construct a CSG solid
  60444. */
  60445. private static FromPolygons;
  60446. /**
  60447. * Clones, or makes a deep copy, of the CSG
  60448. * @returns A new CSG
  60449. */
  60450. clone(): CSG;
  60451. /**
  60452. * Unions this CSG with another CSG
  60453. * @param csg The CSG to union against this CSG
  60454. * @returns The unioned CSG
  60455. */
  60456. union(csg: CSG): CSG;
  60457. /**
  60458. * Unions this CSG with another CSG in place
  60459. * @param csg The CSG to union against this CSG
  60460. */
  60461. unionInPlace(csg: CSG): void;
  60462. /**
  60463. * Subtracts this CSG with another CSG
  60464. * @param csg The CSG to subtract against this CSG
  60465. * @returns A new CSG
  60466. */
  60467. subtract(csg: CSG): CSG;
  60468. /**
  60469. * Subtracts this CSG with another CSG in place
  60470. * @param csg The CSG to subtact against this CSG
  60471. */
  60472. subtractInPlace(csg: CSG): void;
  60473. /**
  60474. * Intersect this CSG with another CSG
  60475. * @param csg The CSG to intersect against this CSG
  60476. * @returns A new CSG
  60477. */
  60478. intersect(csg: CSG): CSG;
  60479. /**
  60480. * Intersects this CSG with another CSG in place
  60481. * @param csg The CSG to intersect against this CSG
  60482. */
  60483. intersectInPlace(csg: CSG): void;
  60484. /**
  60485. * Return a new CSG solid with solid and empty space switched. This solid is
  60486. * not modified.
  60487. * @returns A new CSG solid with solid and empty space switched
  60488. */
  60489. inverse(): CSG;
  60490. /**
  60491. * Inverses the CSG in place
  60492. */
  60493. inverseInPlace(): void;
  60494. /**
  60495. * This is used to keep meshes transformations so they can be restored
  60496. * when we build back a Babylon Mesh
  60497. * NB : All CSG operations are performed in world coordinates
  60498. * @param csg The CSG to copy the transform attributes from
  60499. * @returns This CSG
  60500. */
  60501. copyTransformAttributes(csg: CSG): CSG;
  60502. /**
  60503. * Build Raw mesh from CSG
  60504. * Coordinates here are in world space
  60505. * @param name The name of the mesh geometry
  60506. * @param scene The Scene
  60507. * @param keepSubMeshes Specifies if the submeshes should be kept
  60508. * @returns A new Mesh
  60509. */
  60510. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60511. /**
  60512. * Build Mesh from CSG taking material and transforms into account
  60513. * @param name The name of the Mesh
  60514. * @param material The material of the Mesh
  60515. * @param scene The Scene
  60516. * @param keepSubMeshes Specifies if submeshes should be kept
  60517. * @returns The new Mesh
  60518. */
  60519. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60520. }
  60521. }
  60522. declare module BABYLON {
  60523. /**
  60524. * Class used to create a trail following a mesh
  60525. */
  60526. export class TrailMesh extends Mesh {
  60527. private _generator;
  60528. private _autoStart;
  60529. private _running;
  60530. private _diameter;
  60531. private _length;
  60532. private _sectionPolygonPointsCount;
  60533. private _sectionVectors;
  60534. private _sectionNormalVectors;
  60535. private _beforeRenderObserver;
  60536. /**
  60537. * @constructor
  60538. * @param name The value used by scene.getMeshByName() to do a lookup.
  60539. * @param generator The mesh or transform node to generate a trail.
  60540. * @param scene The scene to add this mesh to.
  60541. * @param diameter Diameter of trailing mesh. Default is 1.
  60542. * @param length Length of trailing mesh. Default is 60.
  60543. * @param autoStart Automatically start trailing mesh. Default true.
  60544. */
  60545. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60546. /**
  60547. * "TrailMesh"
  60548. * @returns "TrailMesh"
  60549. */
  60550. getClassName(): string;
  60551. private _createMesh;
  60552. /**
  60553. * Start trailing mesh.
  60554. */
  60555. start(): void;
  60556. /**
  60557. * Stop trailing mesh.
  60558. */
  60559. stop(): void;
  60560. /**
  60561. * Update trailing mesh geometry.
  60562. */
  60563. update(): void;
  60564. /**
  60565. * Returns a new TrailMesh object.
  60566. * @param name is a string, the name given to the new mesh
  60567. * @param newGenerator use new generator object for cloned trail mesh
  60568. * @returns a new mesh
  60569. */
  60570. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60571. /**
  60572. * Serializes this trail mesh
  60573. * @param serializationObject object to write serialization to
  60574. */
  60575. serialize(serializationObject: any): void;
  60576. /**
  60577. * Parses a serialized trail mesh
  60578. * @param parsedMesh the serialized mesh
  60579. * @param scene the scene to create the trail mesh in
  60580. * @returns the created trail mesh
  60581. */
  60582. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60583. }
  60584. }
  60585. declare module BABYLON {
  60586. /**
  60587. * Class containing static functions to help procedurally build meshes
  60588. */
  60589. export class TiledBoxBuilder {
  60590. /**
  60591. * Creates a box mesh
  60592. * 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)
  60593. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60595. * * 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
  60596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60597. * @param name defines the name of the mesh
  60598. * @param options defines the options used to create the mesh
  60599. * @param scene defines the hosting scene
  60600. * @returns the box mesh
  60601. */
  60602. static CreateTiledBox(name: string, options: {
  60603. pattern?: number;
  60604. width?: number;
  60605. height?: number;
  60606. depth?: number;
  60607. tileSize?: number;
  60608. tileWidth?: number;
  60609. tileHeight?: number;
  60610. alignHorizontal?: number;
  60611. alignVertical?: number;
  60612. faceUV?: Vector4[];
  60613. faceColors?: Color4[];
  60614. sideOrientation?: number;
  60615. updatable?: boolean;
  60616. }, scene?: Nullable<Scene>): Mesh;
  60617. }
  60618. }
  60619. declare module BABYLON {
  60620. /**
  60621. * Class containing static functions to help procedurally build meshes
  60622. */
  60623. export class TorusKnotBuilder {
  60624. /**
  60625. * Creates a torus knot mesh
  60626. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60627. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60628. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60629. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60630. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60631. * * 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
  60632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60633. * @param name defines the name of the mesh
  60634. * @param options defines the options used to create the mesh
  60635. * @param scene defines the hosting scene
  60636. * @returns the torus knot mesh
  60637. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60638. */
  60639. static CreateTorusKnot(name: string, options: {
  60640. radius?: number;
  60641. tube?: number;
  60642. radialSegments?: number;
  60643. tubularSegments?: number;
  60644. p?: number;
  60645. q?: number;
  60646. updatable?: boolean;
  60647. sideOrientation?: number;
  60648. frontUVs?: Vector4;
  60649. backUVs?: Vector4;
  60650. }, scene: any): Mesh;
  60651. }
  60652. }
  60653. declare module BABYLON {
  60654. /**
  60655. * Polygon
  60656. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60657. */
  60658. export class Polygon {
  60659. /**
  60660. * Creates a rectangle
  60661. * @param xmin bottom X coord
  60662. * @param ymin bottom Y coord
  60663. * @param xmax top X coord
  60664. * @param ymax top Y coord
  60665. * @returns points that make the resulting rectation
  60666. */
  60667. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60668. /**
  60669. * Creates a circle
  60670. * @param radius radius of circle
  60671. * @param cx scale in x
  60672. * @param cy scale in y
  60673. * @param numberOfSides number of sides that make up the circle
  60674. * @returns points that make the resulting circle
  60675. */
  60676. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60677. /**
  60678. * Creates a polygon from input string
  60679. * @param input Input polygon data
  60680. * @returns the parsed points
  60681. */
  60682. static Parse(input: string): Vector2[];
  60683. /**
  60684. * Starts building a polygon from x and y coordinates
  60685. * @param x x coordinate
  60686. * @param y y coordinate
  60687. * @returns the started path2
  60688. */
  60689. static StartingAt(x: number, y: number): Path2;
  60690. }
  60691. /**
  60692. * Builds a polygon
  60693. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60694. */
  60695. export class PolygonMeshBuilder {
  60696. private _points;
  60697. private _outlinepoints;
  60698. private _holes;
  60699. private _name;
  60700. private _scene;
  60701. private _epoints;
  60702. private _eholes;
  60703. private _addToepoint;
  60704. /**
  60705. * Babylon reference to the earcut plugin.
  60706. */
  60707. bjsEarcut: any;
  60708. /**
  60709. * Creates a PolygonMeshBuilder
  60710. * @param name name of the builder
  60711. * @param contours Path of the polygon
  60712. * @param scene scene to add to when creating the mesh
  60713. * @param earcutInjection can be used to inject your own earcut reference
  60714. */
  60715. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60716. /**
  60717. * Adds a whole within the polygon
  60718. * @param hole Array of points defining the hole
  60719. * @returns this
  60720. */
  60721. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60722. /**
  60723. * Creates the polygon
  60724. * @param updatable If the mesh should be updatable
  60725. * @param depth The depth of the mesh created
  60726. * @returns the created mesh
  60727. */
  60728. build(updatable?: boolean, depth?: number): Mesh;
  60729. /**
  60730. * Creates the polygon
  60731. * @param depth The depth of the mesh created
  60732. * @returns the created VertexData
  60733. */
  60734. buildVertexData(depth?: number): VertexData;
  60735. /**
  60736. * Adds a side to the polygon
  60737. * @param positions points that make the polygon
  60738. * @param normals normals of the polygon
  60739. * @param uvs uvs of the polygon
  60740. * @param indices indices of the polygon
  60741. * @param bounds bounds of the polygon
  60742. * @param points points of the polygon
  60743. * @param depth depth of the polygon
  60744. * @param flip flip of the polygon
  60745. */
  60746. private addSide;
  60747. }
  60748. }
  60749. declare module BABYLON {
  60750. /**
  60751. * Class containing static functions to help procedurally build meshes
  60752. */
  60753. export class PolygonBuilder {
  60754. /**
  60755. * Creates a polygon mesh
  60756. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60757. * * 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
  60758. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60760. * * 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)
  60761. * * Remember you can only change the shape positions, not their number when updating a polygon
  60762. * @param name defines the name of the mesh
  60763. * @param options defines the options used to create the mesh
  60764. * @param scene defines the hosting scene
  60765. * @param earcutInjection can be used to inject your own earcut reference
  60766. * @returns the polygon mesh
  60767. */
  60768. static CreatePolygon(name: string, options: {
  60769. shape: Vector3[];
  60770. holes?: Vector3[][];
  60771. depth?: number;
  60772. faceUV?: Vector4[];
  60773. faceColors?: Color4[];
  60774. updatable?: boolean;
  60775. sideOrientation?: number;
  60776. frontUVs?: Vector4;
  60777. backUVs?: Vector4;
  60778. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60779. /**
  60780. * Creates an extruded polygon mesh, with depth in the Y direction.
  60781. * * 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)
  60782. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60783. * @param name defines the name of the mesh
  60784. * @param options defines the options used to create the mesh
  60785. * @param scene defines the hosting scene
  60786. * @param earcutInjection can be used to inject your own earcut reference
  60787. * @returns the polygon mesh
  60788. */
  60789. static ExtrudePolygon(name: string, options: {
  60790. shape: Vector3[];
  60791. holes?: Vector3[][];
  60792. depth?: number;
  60793. faceUV?: Vector4[];
  60794. faceColors?: Color4[];
  60795. updatable?: boolean;
  60796. sideOrientation?: number;
  60797. frontUVs?: Vector4;
  60798. backUVs?: Vector4;
  60799. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60800. }
  60801. }
  60802. declare module BABYLON {
  60803. /**
  60804. * Class containing static functions to help procedurally build meshes
  60805. */
  60806. export class LatheBuilder {
  60807. /**
  60808. * Creates lathe mesh.
  60809. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60810. * * 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
  60811. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60812. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60813. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60814. * * 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
  60815. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60816. * * 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
  60817. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60818. * * 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
  60819. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60821. * @param name defines the name of the mesh
  60822. * @param options defines the options used to create the mesh
  60823. * @param scene defines the hosting scene
  60824. * @returns the lathe mesh
  60825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60826. */
  60827. static CreateLathe(name: string, options: {
  60828. shape: Vector3[];
  60829. radius?: number;
  60830. tessellation?: number;
  60831. clip?: number;
  60832. arc?: number;
  60833. closed?: boolean;
  60834. updatable?: boolean;
  60835. sideOrientation?: number;
  60836. frontUVs?: Vector4;
  60837. backUVs?: Vector4;
  60838. cap?: number;
  60839. invertUV?: boolean;
  60840. }, scene?: Nullable<Scene>): Mesh;
  60841. }
  60842. }
  60843. declare module BABYLON {
  60844. /**
  60845. * Class containing static functions to help procedurally build meshes
  60846. */
  60847. export class TiledPlaneBuilder {
  60848. /**
  60849. * Creates a tiled plane mesh
  60850. * * The parameter `pattern` will, depending on value, do nothing or
  60851. * * * flip (reflect about central vertical) alternate tiles across and up
  60852. * * * flip every tile on alternate rows
  60853. * * * rotate (180 degs) alternate tiles across and up
  60854. * * * rotate every tile on alternate rows
  60855. * * * flip and rotate alternate tiles across and up
  60856. * * * flip and rotate every tile on alternate rows
  60857. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60858. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60859. * * 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
  60860. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60861. * * 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)
  60862. * * 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)
  60863. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60864. * @param name defines the name of the mesh
  60865. * @param options defines the options used to create the mesh
  60866. * @param scene defines the hosting scene
  60867. * @returns the box mesh
  60868. */
  60869. static CreateTiledPlane(name: string, options: {
  60870. pattern?: number;
  60871. tileSize?: number;
  60872. tileWidth?: number;
  60873. tileHeight?: number;
  60874. size?: number;
  60875. width?: number;
  60876. height?: number;
  60877. alignHorizontal?: number;
  60878. alignVertical?: number;
  60879. sideOrientation?: number;
  60880. frontUVs?: Vector4;
  60881. backUVs?: Vector4;
  60882. updatable?: boolean;
  60883. }, scene?: Nullable<Scene>): Mesh;
  60884. }
  60885. }
  60886. declare module BABYLON {
  60887. /**
  60888. * Class containing static functions to help procedurally build meshes
  60889. */
  60890. export class TubeBuilder {
  60891. /**
  60892. * Creates a tube mesh.
  60893. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60894. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60895. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60896. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60897. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60898. * * 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)
  60899. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60900. * * 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
  60901. * * 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
  60902. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60903. * * 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
  60904. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60906. * @param name defines the name of the mesh
  60907. * @param options defines the options used to create the mesh
  60908. * @param scene defines the hosting scene
  60909. * @returns the tube mesh
  60910. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60911. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60912. */
  60913. static CreateTube(name: string, options: {
  60914. path: Vector3[];
  60915. radius?: number;
  60916. tessellation?: number;
  60917. radiusFunction?: {
  60918. (i: number, distance: number): number;
  60919. };
  60920. cap?: number;
  60921. arc?: number;
  60922. updatable?: boolean;
  60923. sideOrientation?: number;
  60924. frontUVs?: Vector4;
  60925. backUVs?: Vector4;
  60926. instance?: Mesh;
  60927. invertUV?: boolean;
  60928. }, scene?: Nullable<Scene>): Mesh;
  60929. }
  60930. }
  60931. declare module BABYLON {
  60932. /**
  60933. * Class containing static functions to help procedurally build meshes
  60934. */
  60935. export class IcoSphereBuilder {
  60936. /**
  60937. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60938. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60939. * * 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`)
  60940. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60941. * * 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
  60942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60943. * * 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
  60944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60945. * @param name defines the name of the mesh
  60946. * @param options defines the options used to create the mesh
  60947. * @param scene defines the hosting scene
  60948. * @returns the icosahedron mesh
  60949. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60950. */
  60951. static CreateIcoSphere(name: string, options: {
  60952. radius?: number;
  60953. radiusX?: number;
  60954. radiusY?: number;
  60955. radiusZ?: number;
  60956. flat?: boolean;
  60957. subdivisions?: number;
  60958. sideOrientation?: number;
  60959. frontUVs?: Vector4;
  60960. backUVs?: Vector4;
  60961. updatable?: boolean;
  60962. }, scene?: Nullable<Scene>): Mesh;
  60963. }
  60964. }
  60965. declare module BABYLON {
  60966. /**
  60967. * Class containing static functions to help procedurally build meshes
  60968. */
  60969. export class DecalBuilder {
  60970. /**
  60971. * Creates a decal mesh.
  60972. * 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
  60973. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60974. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60975. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60976. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60977. * @param name defines the name of the mesh
  60978. * @param sourceMesh defines the mesh where the decal must be applied
  60979. * @param options defines the options used to create the mesh
  60980. * @param scene defines the hosting scene
  60981. * @returns the decal mesh
  60982. * @see https://doc.babylonjs.com/how_to/decals
  60983. */
  60984. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60985. position?: Vector3;
  60986. normal?: Vector3;
  60987. size?: Vector3;
  60988. angle?: number;
  60989. }): Mesh;
  60990. }
  60991. }
  60992. declare module BABYLON {
  60993. /**
  60994. * Class containing static functions to help procedurally build meshes
  60995. */
  60996. export class MeshBuilder {
  60997. /**
  60998. * Creates a box mesh
  60999. * * The parameter `size` sets the size (float) of each box side (default 1)
  61000. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61001. * * 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)
  61002. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61004. * * 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
  61005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61006. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61007. * @param name defines the name of the mesh
  61008. * @param options defines the options used to create the mesh
  61009. * @param scene defines the hosting scene
  61010. * @returns the box mesh
  61011. */
  61012. static CreateBox(name: string, options: {
  61013. size?: number;
  61014. width?: number;
  61015. height?: number;
  61016. depth?: number;
  61017. faceUV?: Vector4[];
  61018. faceColors?: Color4[];
  61019. sideOrientation?: number;
  61020. frontUVs?: Vector4;
  61021. backUVs?: Vector4;
  61022. updatable?: boolean;
  61023. }, scene?: Nullable<Scene>): Mesh;
  61024. /**
  61025. * Creates a tiled box mesh
  61026. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61028. * @param name defines the name of the mesh
  61029. * @param options defines the options used to create the mesh
  61030. * @param scene defines the hosting scene
  61031. * @returns the tiled box mesh
  61032. */
  61033. static CreateTiledBox(name: string, options: {
  61034. pattern?: number;
  61035. size?: number;
  61036. width?: number;
  61037. height?: number;
  61038. depth: number;
  61039. tileSize?: number;
  61040. tileWidth?: number;
  61041. tileHeight?: number;
  61042. faceUV?: Vector4[];
  61043. faceColors?: Color4[];
  61044. alignHorizontal?: number;
  61045. alignVertical?: number;
  61046. sideOrientation?: number;
  61047. updatable?: boolean;
  61048. }, scene?: Nullable<Scene>): Mesh;
  61049. /**
  61050. * Creates a sphere mesh
  61051. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61052. * * 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`)
  61053. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61054. * * 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
  61055. * * 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)
  61056. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61057. * * 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
  61058. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61059. * @param name defines the name of the mesh
  61060. * @param options defines the options used to create the mesh
  61061. * @param scene defines the hosting scene
  61062. * @returns the sphere mesh
  61063. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61064. */
  61065. static CreateSphere(name: string, options: {
  61066. segments?: number;
  61067. diameter?: number;
  61068. diameterX?: number;
  61069. diameterY?: number;
  61070. diameterZ?: number;
  61071. arc?: number;
  61072. slice?: number;
  61073. sideOrientation?: number;
  61074. frontUVs?: Vector4;
  61075. backUVs?: Vector4;
  61076. updatable?: boolean;
  61077. }, scene?: Nullable<Scene>): Mesh;
  61078. /**
  61079. * Creates a plane polygonal mesh. By default, this is a disc
  61080. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61081. * * 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
  61082. * * 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
  61083. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61084. * * 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
  61085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61086. * @param name defines the name of the mesh
  61087. * @param options defines the options used to create the mesh
  61088. * @param scene defines the hosting scene
  61089. * @returns the plane polygonal mesh
  61090. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61091. */
  61092. static CreateDisc(name: string, options: {
  61093. radius?: number;
  61094. tessellation?: number;
  61095. arc?: number;
  61096. updatable?: boolean;
  61097. sideOrientation?: number;
  61098. frontUVs?: Vector4;
  61099. backUVs?: Vector4;
  61100. }, scene?: Nullable<Scene>): Mesh;
  61101. /**
  61102. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61103. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61104. * * 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`)
  61105. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61106. * * 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
  61107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61108. * * 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
  61109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61110. * @param name defines the name of the mesh
  61111. * @param options defines the options used to create the mesh
  61112. * @param scene defines the hosting scene
  61113. * @returns the icosahedron mesh
  61114. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61115. */
  61116. static CreateIcoSphere(name: string, options: {
  61117. radius?: number;
  61118. radiusX?: number;
  61119. radiusY?: number;
  61120. radiusZ?: number;
  61121. flat?: boolean;
  61122. subdivisions?: number;
  61123. sideOrientation?: number;
  61124. frontUVs?: Vector4;
  61125. backUVs?: Vector4;
  61126. updatable?: boolean;
  61127. }, scene?: Nullable<Scene>): Mesh;
  61128. /**
  61129. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61130. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61131. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61132. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61133. * * 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
  61134. * * 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
  61135. * * 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
  61136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61137. * * 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
  61138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61139. * * 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
  61140. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61141. * * 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
  61142. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61144. * @param name defines the name of the mesh
  61145. * @param options defines the options used to create the mesh
  61146. * @param scene defines the hosting scene
  61147. * @returns the ribbon mesh
  61148. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61149. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61150. */
  61151. static CreateRibbon(name: string, options: {
  61152. pathArray: Vector3[][];
  61153. closeArray?: boolean;
  61154. closePath?: boolean;
  61155. offset?: number;
  61156. updatable?: boolean;
  61157. sideOrientation?: number;
  61158. frontUVs?: Vector4;
  61159. backUVs?: Vector4;
  61160. instance?: Mesh;
  61161. invertUV?: boolean;
  61162. uvs?: Vector2[];
  61163. colors?: Color4[];
  61164. }, scene?: Nullable<Scene>): Mesh;
  61165. /**
  61166. * Creates a cylinder or a cone mesh
  61167. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61168. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61169. * * 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.
  61170. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61171. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61172. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61173. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61174. * * 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).
  61175. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61176. * * 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).
  61177. * * 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
  61178. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61179. * * 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
  61180. * * 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.
  61181. * * If `enclose` is false, a ring surface is one element.
  61182. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61183. * * 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
  61184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61185. * * 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
  61186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61187. * @param name defines the name of the mesh
  61188. * @param options defines the options used to create the mesh
  61189. * @param scene defines the hosting scene
  61190. * @returns the cylinder mesh
  61191. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61192. */
  61193. static CreateCylinder(name: string, options: {
  61194. height?: number;
  61195. diameterTop?: number;
  61196. diameterBottom?: number;
  61197. diameter?: number;
  61198. tessellation?: number;
  61199. subdivisions?: number;
  61200. arc?: number;
  61201. faceColors?: Color4[];
  61202. faceUV?: Vector4[];
  61203. updatable?: boolean;
  61204. hasRings?: boolean;
  61205. enclose?: boolean;
  61206. cap?: number;
  61207. sideOrientation?: number;
  61208. frontUVs?: Vector4;
  61209. backUVs?: Vector4;
  61210. }, scene?: Nullable<Scene>): Mesh;
  61211. /**
  61212. * Creates a torus mesh
  61213. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61214. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61215. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61217. * * 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
  61218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61219. * @param name defines the name of the mesh
  61220. * @param options defines the options used to create the mesh
  61221. * @param scene defines the hosting scene
  61222. * @returns the torus mesh
  61223. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61224. */
  61225. static CreateTorus(name: string, options: {
  61226. diameter?: number;
  61227. thickness?: number;
  61228. tessellation?: number;
  61229. updatable?: boolean;
  61230. sideOrientation?: number;
  61231. frontUVs?: Vector4;
  61232. backUVs?: Vector4;
  61233. }, scene?: Nullable<Scene>): Mesh;
  61234. /**
  61235. * Creates a torus knot mesh
  61236. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61237. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61238. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61239. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61241. * * 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
  61242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61243. * @param name defines the name of the mesh
  61244. * @param options defines the options used to create the mesh
  61245. * @param scene defines the hosting scene
  61246. * @returns the torus knot mesh
  61247. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61248. */
  61249. static CreateTorusKnot(name: string, options: {
  61250. radius?: number;
  61251. tube?: number;
  61252. radialSegments?: number;
  61253. tubularSegments?: number;
  61254. p?: number;
  61255. q?: number;
  61256. updatable?: boolean;
  61257. sideOrientation?: number;
  61258. frontUVs?: Vector4;
  61259. backUVs?: Vector4;
  61260. }, scene?: Nullable<Scene>): Mesh;
  61261. /**
  61262. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61263. * * 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
  61264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61265. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61266. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61267. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61268. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61269. * * 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
  61270. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61272. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61273. * @param name defines the name of the new line system
  61274. * @param options defines the options used to create the line system
  61275. * @param scene defines the hosting scene
  61276. * @returns a new line system mesh
  61277. */
  61278. static CreateLineSystem(name: string, options: {
  61279. lines: Vector3[][];
  61280. updatable?: boolean;
  61281. instance?: Nullable<LinesMesh>;
  61282. colors?: Nullable<Color4[][]>;
  61283. useVertexAlpha?: boolean;
  61284. }, scene: Nullable<Scene>): LinesMesh;
  61285. /**
  61286. * Creates a line mesh
  61287. * 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
  61288. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61289. * * The parameter `points` is an array successive Vector3
  61290. * * 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
  61291. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61292. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61293. * * When updating an instance, remember that only point positions can change, not the number of points
  61294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61296. * @param name defines the name of the new line system
  61297. * @param options defines the options used to create the line system
  61298. * @param scene defines the hosting scene
  61299. * @returns a new line mesh
  61300. */
  61301. static CreateLines(name: string, options: {
  61302. points: Vector3[];
  61303. updatable?: boolean;
  61304. instance?: Nullable<LinesMesh>;
  61305. colors?: Color4[];
  61306. useVertexAlpha?: boolean;
  61307. }, scene?: Nullable<Scene>): LinesMesh;
  61308. /**
  61309. * Creates a dashed line mesh
  61310. * * 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
  61311. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61312. * * The parameter `points` is an array successive Vector3
  61313. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61314. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61315. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61316. * * 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
  61317. * * When updating an instance, remember that only point positions can change, not the number of points
  61318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61319. * @param name defines the name of the mesh
  61320. * @param options defines the options used to create the mesh
  61321. * @param scene defines the hosting scene
  61322. * @returns the dashed line mesh
  61323. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61324. */
  61325. static CreateDashedLines(name: string, options: {
  61326. points: Vector3[];
  61327. dashSize?: number;
  61328. gapSize?: number;
  61329. dashNb?: number;
  61330. updatable?: boolean;
  61331. instance?: LinesMesh;
  61332. }, scene?: Nullable<Scene>): LinesMesh;
  61333. /**
  61334. * 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.
  61335. * * 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.
  61336. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61337. * * 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.
  61338. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61339. * * 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
  61340. * * 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
  61341. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61343. * * 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
  61344. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61346. * @param name defines the name of the mesh
  61347. * @param options defines the options used to create the mesh
  61348. * @param scene defines the hosting scene
  61349. * @returns the extruded shape mesh
  61350. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61352. */
  61353. static ExtrudeShape(name: string, options: {
  61354. shape: Vector3[];
  61355. path: Vector3[];
  61356. scale?: number;
  61357. rotation?: number;
  61358. cap?: number;
  61359. updatable?: boolean;
  61360. sideOrientation?: number;
  61361. frontUVs?: Vector4;
  61362. backUVs?: Vector4;
  61363. instance?: Mesh;
  61364. invertUV?: boolean;
  61365. }, scene?: Nullable<Scene>): Mesh;
  61366. /**
  61367. * Creates an custom extruded shape mesh.
  61368. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61369. * * 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.
  61370. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61371. * * 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
  61372. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61373. * * 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
  61374. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61375. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61376. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61377. * * 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
  61378. * * 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
  61379. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61381. * * 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
  61382. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61384. * @param name defines the name of the mesh
  61385. * @param options defines the options used to create the mesh
  61386. * @param scene defines the hosting scene
  61387. * @returns the custom extruded shape mesh
  61388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61389. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61390. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61391. */
  61392. static ExtrudeShapeCustom(name: string, options: {
  61393. shape: Vector3[];
  61394. path: Vector3[];
  61395. scaleFunction?: any;
  61396. rotationFunction?: any;
  61397. ribbonCloseArray?: boolean;
  61398. ribbonClosePath?: boolean;
  61399. cap?: number;
  61400. updatable?: boolean;
  61401. sideOrientation?: number;
  61402. frontUVs?: Vector4;
  61403. backUVs?: Vector4;
  61404. instance?: Mesh;
  61405. invertUV?: boolean;
  61406. }, scene?: Nullable<Scene>): Mesh;
  61407. /**
  61408. * Creates lathe mesh.
  61409. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61410. * * 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
  61411. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61412. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61413. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61414. * * 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
  61415. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61416. * * 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
  61417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61418. * * 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
  61419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61421. * @param name defines the name of the mesh
  61422. * @param options defines the options used to create the mesh
  61423. * @param scene defines the hosting scene
  61424. * @returns the lathe mesh
  61425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61426. */
  61427. static CreateLathe(name: string, options: {
  61428. shape: Vector3[];
  61429. radius?: number;
  61430. tessellation?: number;
  61431. clip?: number;
  61432. arc?: number;
  61433. closed?: boolean;
  61434. updatable?: boolean;
  61435. sideOrientation?: number;
  61436. frontUVs?: Vector4;
  61437. backUVs?: Vector4;
  61438. cap?: number;
  61439. invertUV?: boolean;
  61440. }, scene?: Nullable<Scene>): Mesh;
  61441. /**
  61442. * Creates a tiled plane mesh
  61443. * * You can set a limited pattern arrangement with the tiles
  61444. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61445. * * 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
  61446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61447. * @param name defines the name of the mesh
  61448. * @param options defines the options used to create the mesh
  61449. * @param scene defines the hosting scene
  61450. * @returns the plane mesh
  61451. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61452. */
  61453. static CreateTiledPlane(name: string, options: {
  61454. pattern?: number;
  61455. tileSize?: number;
  61456. tileWidth?: number;
  61457. tileHeight?: number;
  61458. size?: number;
  61459. width?: number;
  61460. height?: number;
  61461. alignHorizontal?: number;
  61462. alignVertical?: number;
  61463. sideOrientation?: number;
  61464. frontUVs?: Vector4;
  61465. backUVs?: Vector4;
  61466. updatable?: boolean;
  61467. }, scene?: Nullable<Scene>): Mesh;
  61468. /**
  61469. * Creates a plane mesh
  61470. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61471. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61472. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61473. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61474. * * 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
  61475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61476. * @param name defines the name of the mesh
  61477. * @param options defines the options used to create the mesh
  61478. * @param scene defines the hosting scene
  61479. * @returns the plane mesh
  61480. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61481. */
  61482. static CreatePlane(name: string, options: {
  61483. size?: number;
  61484. width?: number;
  61485. height?: number;
  61486. sideOrientation?: number;
  61487. frontUVs?: Vector4;
  61488. backUVs?: Vector4;
  61489. updatable?: boolean;
  61490. sourcePlane?: Plane;
  61491. }, scene?: Nullable<Scene>): Mesh;
  61492. /**
  61493. * Creates a ground mesh
  61494. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61495. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61496. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61497. * @param name defines the name of the mesh
  61498. * @param options defines the options used to create the mesh
  61499. * @param scene defines the hosting scene
  61500. * @returns the ground mesh
  61501. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61502. */
  61503. static CreateGround(name: string, options: {
  61504. width?: number;
  61505. height?: number;
  61506. subdivisions?: number;
  61507. subdivisionsX?: number;
  61508. subdivisionsY?: number;
  61509. updatable?: boolean;
  61510. }, scene?: Nullable<Scene>): Mesh;
  61511. /**
  61512. * Creates a tiled ground mesh
  61513. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61514. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61515. * * 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
  61516. * * 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
  61517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61518. * @param name defines the name of the mesh
  61519. * @param options defines the options used to create the mesh
  61520. * @param scene defines the hosting scene
  61521. * @returns the tiled ground mesh
  61522. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61523. */
  61524. static CreateTiledGround(name: string, options: {
  61525. xmin: number;
  61526. zmin: number;
  61527. xmax: number;
  61528. zmax: number;
  61529. subdivisions?: {
  61530. w: number;
  61531. h: number;
  61532. };
  61533. precision?: {
  61534. w: number;
  61535. h: number;
  61536. };
  61537. updatable?: boolean;
  61538. }, scene?: Nullable<Scene>): Mesh;
  61539. /**
  61540. * Creates a ground mesh from a height map
  61541. * * The parameter `url` sets the URL of the height map image resource.
  61542. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61543. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61544. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61545. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61546. * * 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.
  61547. * * 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).
  61548. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61550. * @param name defines the name of the mesh
  61551. * @param url defines the url to the height map
  61552. * @param options defines the options used to create the mesh
  61553. * @param scene defines the hosting scene
  61554. * @returns the ground mesh
  61555. * @see https://doc.babylonjs.com/babylon101/height_map
  61556. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61557. */
  61558. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61559. width?: number;
  61560. height?: number;
  61561. subdivisions?: number;
  61562. minHeight?: number;
  61563. maxHeight?: number;
  61564. colorFilter?: Color3;
  61565. alphaFilter?: number;
  61566. updatable?: boolean;
  61567. onReady?: (mesh: GroundMesh) => void;
  61568. }, scene?: Nullable<Scene>): GroundMesh;
  61569. /**
  61570. * Creates a polygon mesh
  61571. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61572. * * 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
  61573. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61575. * * 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)
  61576. * * Remember you can only change the shape positions, not their number when updating a polygon
  61577. * @param name defines the name of the mesh
  61578. * @param options defines the options used to create the mesh
  61579. * @param scene defines the hosting scene
  61580. * @param earcutInjection can be used to inject your own earcut reference
  61581. * @returns the polygon mesh
  61582. */
  61583. static CreatePolygon(name: string, options: {
  61584. shape: Vector3[];
  61585. holes?: Vector3[][];
  61586. depth?: number;
  61587. faceUV?: Vector4[];
  61588. faceColors?: Color4[];
  61589. updatable?: boolean;
  61590. sideOrientation?: number;
  61591. frontUVs?: Vector4;
  61592. backUVs?: Vector4;
  61593. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61594. /**
  61595. * Creates an extruded polygon mesh, with depth in the Y direction.
  61596. * * 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)
  61597. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61598. * @param name defines the name of the mesh
  61599. * @param options defines the options used to create the mesh
  61600. * @param scene defines the hosting scene
  61601. * @param earcutInjection can be used to inject your own earcut reference
  61602. * @returns the polygon mesh
  61603. */
  61604. static ExtrudePolygon(name: string, options: {
  61605. shape: Vector3[];
  61606. holes?: Vector3[][];
  61607. depth?: number;
  61608. faceUV?: Vector4[];
  61609. faceColors?: Color4[];
  61610. updatable?: boolean;
  61611. sideOrientation?: number;
  61612. frontUVs?: Vector4;
  61613. backUVs?: Vector4;
  61614. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61615. /**
  61616. * Creates a tube mesh.
  61617. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61618. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61619. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61620. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61621. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61622. * * 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)
  61623. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61624. * * 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
  61625. * * 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
  61626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61627. * * 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
  61628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61630. * @param name defines the name of the mesh
  61631. * @param options defines the options used to create the mesh
  61632. * @param scene defines the hosting scene
  61633. * @returns the tube mesh
  61634. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61635. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61636. */
  61637. static CreateTube(name: string, options: {
  61638. path: Vector3[];
  61639. radius?: number;
  61640. tessellation?: number;
  61641. radiusFunction?: {
  61642. (i: number, distance: number): number;
  61643. };
  61644. cap?: number;
  61645. arc?: number;
  61646. updatable?: boolean;
  61647. sideOrientation?: number;
  61648. frontUVs?: Vector4;
  61649. backUVs?: Vector4;
  61650. instance?: Mesh;
  61651. invertUV?: boolean;
  61652. }, scene?: Nullable<Scene>): Mesh;
  61653. /**
  61654. * Creates a polyhedron mesh
  61655. * * 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
  61656. * * The parameter `size` (positive float, default 1) sets the polygon size
  61657. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61658. * * 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`
  61659. * * 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
  61660. * * 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)`)
  61661. * * 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
  61662. * * 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
  61663. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61664. * * 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
  61665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61666. * @param name defines the name of the mesh
  61667. * @param options defines the options used to create the mesh
  61668. * @param scene defines the hosting scene
  61669. * @returns the polyhedron mesh
  61670. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61671. */
  61672. static CreatePolyhedron(name: string, options: {
  61673. type?: number;
  61674. size?: number;
  61675. sizeX?: number;
  61676. sizeY?: number;
  61677. sizeZ?: number;
  61678. custom?: any;
  61679. faceUV?: Vector4[];
  61680. faceColors?: Color4[];
  61681. flat?: boolean;
  61682. updatable?: boolean;
  61683. sideOrientation?: number;
  61684. frontUVs?: Vector4;
  61685. backUVs?: Vector4;
  61686. }, scene?: Nullable<Scene>): Mesh;
  61687. /**
  61688. * Creates a decal mesh.
  61689. * 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
  61690. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61691. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61692. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61693. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61694. * @param name defines the name of the mesh
  61695. * @param sourceMesh defines the mesh where the decal must be applied
  61696. * @param options defines the options used to create the mesh
  61697. * @param scene defines the hosting scene
  61698. * @returns the decal mesh
  61699. * @see https://doc.babylonjs.com/how_to/decals
  61700. */
  61701. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61702. position?: Vector3;
  61703. normal?: Vector3;
  61704. size?: Vector3;
  61705. angle?: number;
  61706. }): Mesh;
  61707. }
  61708. }
  61709. declare module BABYLON {
  61710. /**
  61711. * A simplifier interface for future simplification implementations
  61712. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61713. */
  61714. export interface ISimplifier {
  61715. /**
  61716. * Simplification of a given mesh according to the given settings.
  61717. * Since this requires computation, it is assumed that the function runs async.
  61718. * @param settings The settings of the simplification, including quality and distance
  61719. * @param successCallback A callback that will be called after the mesh was simplified.
  61720. * @param errorCallback in case of an error, this callback will be called. optional.
  61721. */
  61722. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61723. }
  61724. /**
  61725. * Expected simplification settings.
  61726. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61727. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61728. */
  61729. export interface ISimplificationSettings {
  61730. /**
  61731. * Gets or sets the expected quality
  61732. */
  61733. quality: number;
  61734. /**
  61735. * Gets or sets the distance when this optimized version should be used
  61736. */
  61737. distance: number;
  61738. /**
  61739. * Gets an already optimized mesh
  61740. */
  61741. optimizeMesh?: boolean;
  61742. }
  61743. /**
  61744. * Class used to specify simplification options
  61745. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61746. */
  61747. export class SimplificationSettings implements ISimplificationSettings {
  61748. /** expected quality */
  61749. quality: number;
  61750. /** distance when this optimized version should be used */
  61751. distance: number;
  61752. /** already optimized mesh */
  61753. optimizeMesh?: boolean | undefined;
  61754. /**
  61755. * Creates a SimplificationSettings
  61756. * @param quality expected quality
  61757. * @param distance distance when this optimized version should be used
  61758. * @param optimizeMesh already optimized mesh
  61759. */
  61760. constructor(
  61761. /** expected quality */
  61762. quality: number,
  61763. /** distance when this optimized version should be used */
  61764. distance: number,
  61765. /** already optimized mesh */
  61766. optimizeMesh?: boolean | undefined);
  61767. }
  61768. /**
  61769. * Interface used to define a simplification task
  61770. */
  61771. export interface ISimplificationTask {
  61772. /**
  61773. * Array of settings
  61774. */
  61775. settings: Array<ISimplificationSettings>;
  61776. /**
  61777. * Simplification type
  61778. */
  61779. simplificationType: SimplificationType;
  61780. /**
  61781. * Mesh to simplify
  61782. */
  61783. mesh: Mesh;
  61784. /**
  61785. * Callback called on success
  61786. */
  61787. successCallback?: () => void;
  61788. /**
  61789. * Defines if parallel processing can be used
  61790. */
  61791. parallelProcessing: boolean;
  61792. }
  61793. /**
  61794. * Queue used to order the simplification tasks
  61795. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61796. */
  61797. export class SimplificationQueue {
  61798. private _simplificationArray;
  61799. /**
  61800. * Gets a boolean indicating that the process is still running
  61801. */
  61802. running: boolean;
  61803. /**
  61804. * Creates a new queue
  61805. */
  61806. constructor();
  61807. /**
  61808. * Adds a new simplification task
  61809. * @param task defines a task to add
  61810. */
  61811. addTask(task: ISimplificationTask): void;
  61812. /**
  61813. * Execute next task
  61814. */
  61815. executeNext(): void;
  61816. /**
  61817. * Execute a simplification task
  61818. * @param task defines the task to run
  61819. */
  61820. runSimplification(task: ISimplificationTask): void;
  61821. private getSimplifier;
  61822. }
  61823. /**
  61824. * The implemented types of simplification
  61825. * At the moment only Quadratic Error Decimation is implemented
  61826. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61827. */
  61828. export enum SimplificationType {
  61829. /** Quadratic error decimation */
  61830. QUADRATIC = 0
  61831. }
  61832. }
  61833. declare module BABYLON {
  61834. interface Scene {
  61835. /** @hidden (Backing field) */
  61836. _simplificationQueue: SimplificationQueue;
  61837. /**
  61838. * Gets or sets the simplification queue attached to the scene
  61839. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61840. */
  61841. simplificationQueue: SimplificationQueue;
  61842. }
  61843. interface Mesh {
  61844. /**
  61845. * Simplify the mesh according to the given array of settings.
  61846. * Function will return immediately and will simplify async
  61847. * @param settings a collection of simplification settings
  61848. * @param parallelProcessing should all levels calculate parallel or one after the other
  61849. * @param simplificationType the type of simplification to run
  61850. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61851. * @returns the current mesh
  61852. */
  61853. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61854. }
  61855. /**
  61856. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61857. * created in a scene
  61858. */
  61859. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61860. /**
  61861. * The component name helpfull to identify the component in the list of scene components.
  61862. */
  61863. readonly name: string;
  61864. /**
  61865. * The scene the component belongs to.
  61866. */
  61867. scene: Scene;
  61868. /**
  61869. * Creates a new instance of the component for the given scene
  61870. * @param scene Defines the scene to register the component in
  61871. */
  61872. constructor(scene: Scene);
  61873. /**
  61874. * Registers the component in a given scene
  61875. */
  61876. register(): void;
  61877. /**
  61878. * Rebuilds the elements related to this component in case of
  61879. * context lost for instance.
  61880. */
  61881. rebuild(): void;
  61882. /**
  61883. * Disposes the component and the associated ressources
  61884. */
  61885. dispose(): void;
  61886. private _beforeCameraUpdate;
  61887. }
  61888. }
  61889. declare module BABYLON {
  61890. /**
  61891. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61892. */
  61893. export interface INavigationEnginePlugin {
  61894. /**
  61895. * plugin name
  61896. */
  61897. name: string;
  61898. /**
  61899. * Creates a navigation mesh
  61900. * @param meshes array of all the geometry used to compute the navigatio mesh
  61901. * @param parameters bunch of parameters used to filter geometry
  61902. */
  61903. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61904. /**
  61905. * Create a navigation mesh debug mesh
  61906. * @param scene is where the mesh will be added
  61907. * @returns debug display mesh
  61908. */
  61909. createDebugNavMesh(scene: Scene): Mesh;
  61910. /**
  61911. * Get a navigation mesh constrained position, closest to the parameter position
  61912. * @param position world position
  61913. * @returns the closest point to position constrained by the navigation mesh
  61914. */
  61915. getClosestPoint(position: Vector3): Vector3;
  61916. /**
  61917. * Get a navigation mesh constrained position, within a particular radius
  61918. * @param position world position
  61919. * @param maxRadius the maximum distance to the constrained world position
  61920. * @returns the closest point to position constrained by the navigation mesh
  61921. */
  61922. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61923. /**
  61924. * Compute the final position from a segment made of destination-position
  61925. * @param position world position
  61926. * @param destination world position
  61927. * @returns the resulting point along the navmesh
  61928. */
  61929. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61930. /**
  61931. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61932. * @param start world position
  61933. * @param end world position
  61934. * @returns array containing world position composing the path
  61935. */
  61936. computePath(start: Vector3, end: Vector3): Vector3[];
  61937. /**
  61938. * If this plugin is supported
  61939. * @returns true if plugin is supported
  61940. */
  61941. isSupported(): boolean;
  61942. /**
  61943. * Create a new Crowd so you can add agents
  61944. * @param maxAgents the maximum agent count in the crowd
  61945. * @param maxAgentRadius the maximum radius an agent can have
  61946. * @param scene to attach the crowd to
  61947. * @returns the crowd you can add agents to
  61948. */
  61949. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61950. /**
  61951. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61952. * The queries will try to find a solution within those bounds
  61953. * default is (1,1,1)
  61954. * @param extent x,y,z value that define the extent around the queries point of reference
  61955. */
  61956. setDefaultQueryExtent(extent: Vector3): void;
  61957. /**
  61958. * Get the Bounding box extent specified by setDefaultQueryExtent
  61959. * @returns the box extent values
  61960. */
  61961. getDefaultQueryExtent(): Vector3;
  61962. /**
  61963. * Release all resources
  61964. */
  61965. dispose(): void;
  61966. }
  61967. /**
  61968. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61969. */
  61970. export interface ICrowd {
  61971. /**
  61972. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61973. * You can attach anything to that node. The node position is updated in the scene update tick.
  61974. * @param pos world position that will be constrained by the navigation mesh
  61975. * @param parameters agent parameters
  61976. * @param transform hooked to the agent that will be update by the scene
  61977. * @returns agent index
  61978. */
  61979. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61980. /**
  61981. * Returns the agent position in world space
  61982. * @param index agent index returned by addAgent
  61983. * @returns world space position
  61984. */
  61985. getAgentPosition(index: number): Vector3;
  61986. /**
  61987. * Gets the agent velocity in world space
  61988. * @param index agent index returned by addAgent
  61989. * @returns world space velocity
  61990. */
  61991. getAgentVelocity(index: number): Vector3;
  61992. /**
  61993. * remove a particular agent previously created
  61994. * @param index agent index returned by addAgent
  61995. */
  61996. removeAgent(index: number): void;
  61997. /**
  61998. * get the list of all agents attached to this crowd
  61999. * @returns list of agent indices
  62000. */
  62001. getAgents(): number[];
  62002. /**
  62003. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62004. * @param deltaTime in seconds
  62005. */
  62006. update(deltaTime: number): void;
  62007. /**
  62008. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62009. * @param index agent index returned by addAgent
  62010. * @param destination targeted world position
  62011. */
  62012. agentGoto(index: number, destination: Vector3): void;
  62013. /**
  62014. * Teleport the agent to a new position
  62015. * @param index agent index returned by addAgent
  62016. * @param destination targeted world position
  62017. */
  62018. agentTeleport(index: number, destination: Vector3): void;
  62019. /**
  62020. * Update agent parameters
  62021. * @param index agent index returned by addAgent
  62022. * @param parameters agent parameters
  62023. */
  62024. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62025. /**
  62026. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62027. * The queries will try to find a solution within those bounds
  62028. * default is (1,1,1)
  62029. * @param extent x,y,z value that define the extent around the queries point of reference
  62030. */
  62031. setDefaultQueryExtent(extent: Vector3): void;
  62032. /**
  62033. * Get the Bounding box extent specified by setDefaultQueryExtent
  62034. * @returns the box extent values
  62035. */
  62036. getDefaultQueryExtent(): Vector3;
  62037. /**
  62038. * Release all resources
  62039. */
  62040. dispose(): void;
  62041. }
  62042. /**
  62043. * Configures an agent
  62044. */
  62045. export interface IAgentParameters {
  62046. /**
  62047. * Agent radius. [Limit: >= 0]
  62048. */
  62049. radius: number;
  62050. /**
  62051. * Agent height. [Limit: > 0]
  62052. */
  62053. height: number;
  62054. /**
  62055. * Maximum allowed acceleration. [Limit: >= 0]
  62056. */
  62057. maxAcceleration: number;
  62058. /**
  62059. * Maximum allowed speed. [Limit: >= 0]
  62060. */
  62061. maxSpeed: number;
  62062. /**
  62063. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62064. */
  62065. collisionQueryRange: number;
  62066. /**
  62067. * The path visibility optimization range. [Limit: > 0]
  62068. */
  62069. pathOptimizationRange: number;
  62070. /**
  62071. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62072. */
  62073. separationWeight: number;
  62074. }
  62075. /**
  62076. * Configures the navigation mesh creation
  62077. */
  62078. export interface INavMeshParameters {
  62079. /**
  62080. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62081. */
  62082. cs: number;
  62083. /**
  62084. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62085. */
  62086. ch: number;
  62087. /**
  62088. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62089. */
  62090. walkableSlopeAngle: number;
  62091. /**
  62092. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62093. * be considered walkable. [Limit: >= 3] [Units: vx]
  62094. */
  62095. walkableHeight: number;
  62096. /**
  62097. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62098. */
  62099. walkableClimb: number;
  62100. /**
  62101. * The distance to erode/shrink the walkable area of the heightfield away from
  62102. * obstructions. [Limit: >=0] [Units: vx]
  62103. */
  62104. walkableRadius: number;
  62105. /**
  62106. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62107. */
  62108. maxEdgeLen: number;
  62109. /**
  62110. * The maximum distance a simplfied contour's border edges should deviate
  62111. * the original raw contour. [Limit: >=0] [Units: vx]
  62112. */
  62113. maxSimplificationError: number;
  62114. /**
  62115. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62116. */
  62117. minRegionArea: number;
  62118. /**
  62119. * Any regions with a span count smaller than this value will, if possible,
  62120. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62121. */
  62122. mergeRegionArea: number;
  62123. /**
  62124. * The maximum number of vertices allowed for polygons generated during the
  62125. * contour to polygon conversion process. [Limit: >= 3]
  62126. */
  62127. maxVertsPerPoly: number;
  62128. /**
  62129. * Sets the sampling distance to use when generating the detail mesh.
  62130. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62131. */
  62132. detailSampleDist: number;
  62133. /**
  62134. * The maximum distance the detail mesh surface should deviate from heightfield
  62135. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62136. */
  62137. detailSampleMaxError: number;
  62138. }
  62139. }
  62140. declare module BABYLON {
  62141. /**
  62142. * RecastJS navigation plugin
  62143. */
  62144. export class RecastJSPlugin implements INavigationEnginePlugin {
  62145. /**
  62146. * Reference to the Recast library
  62147. */
  62148. bjsRECAST: any;
  62149. /**
  62150. * plugin name
  62151. */
  62152. name: string;
  62153. /**
  62154. * the first navmesh created. We might extend this to support multiple navmeshes
  62155. */
  62156. navMesh: any;
  62157. /**
  62158. * Initializes the recastJS plugin
  62159. * @param recastInjection can be used to inject your own recast reference
  62160. */
  62161. constructor(recastInjection?: any);
  62162. /**
  62163. * Creates a navigation mesh
  62164. * @param meshes array of all the geometry used to compute the navigatio mesh
  62165. * @param parameters bunch of parameters used to filter geometry
  62166. */
  62167. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62168. /**
  62169. * Create a navigation mesh debug mesh
  62170. * @param scene is where the mesh will be added
  62171. * @returns debug display mesh
  62172. */
  62173. createDebugNavMesh(scene: Scene): Mesh;
  62174. /**
  62175. * Get a navigation mesh constrained position, closest to the parameter position
  62176. * @param position world position
  62177. * @returns the closest point to position constrained by the navigation mesh
  62178. */
  62179. getClosestPoint(position: Vector3): Vector3;
  62180. /**
  62181. * Get a navigation mesh constrained position, within a particular radius
  62182. * @param position world position
  62183. * @param maxRadius the maximum distance to the constrained world position
  62184. * @returns the closest point to position constrained by the navigation mesh
  62185. */
  62186. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62187. /**
  62188. * Compute the final position from a segment made of destination-position
  62189. * @param position world position
  62190. * @param destination world position
  62191. * @returns the resulting point along the navmesh
  62192. */
  62193. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62194. /**
  62195. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62196. * @param start world position
  62197. * @param end world position
  62198. * @returns array containing world position composing the path
  62199. */
  62200. computePath(start: Vector3, end: Vector3): Vector3[];
  62201. /**
  62202. * Create a new Crowd so you can add agents
  62203. * @param maxAgents the maximum agent count in the crowd
  62204. * @param maxAgentRadius the maximum radius an agent can have
  62205. * @param scene to attach the crowd to
  62206. * @returns the crowd you can add agents to
  62207. */
  62208. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62209. /**
  62210. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62211. * The queries will try to find a solution within those bounds
  62212. * default is (1,1,1)
  62213. * @param extent x,y,z value that define the extent around the queries point of reference
  62214. */
  62215. setDefaultQueryExtent(extent: Vector3): void;
  62216. /**
  62217. * Get the Bounding box extent specified by setDefaultQueryExtent
  62218. * @returns the box extent values
  62219. */
  62220. getDefaultQueryExtent(): Vector3;
  62221. /**
  62222. * Disposes
  62223. */
  62224. dispose(): void;
  62225. /**
  62226. * If this plugin is supported
  62227. * @returns true if plugin is supported
  62228. */
  62229. isSupported(): boolean;
  62230. }
  62231. /**
  62232. * Recast detour crowd implementation
  62233. */
  62234. export class RecastJSCrowd implements ICrowd {
  62235. /**
  62236. * Recast/detour plugin
  62237. */
  62238. bjsRECASTPlugin: RecastJSPlugin;
  62239. /**
  62240. * Link to the detour crowd
  62241. */
  62242. recastCrowd: any;
  62243. /**
  62244. * One transform per agent
  62245. */
  62246. transforms: TransformNode[];
  62247. /**
  62248. * All agents created
  62249. */
  62250. agents: number[];
  62251. /**
  62252. * Link to the scene is kept to unregister the crowd from the scene
  62253. */
  62254. private _scene;
  62255. /**
  62256. * Observer for crowd updates
  62257. */
  62258. private _onBeforeAnimationsObserver;
  62259. /**
  62260. * Constructor
  62261. * @param plugin recastJS plugin
  62262. * @param maxAgents the maximum agent count in the crowd
  62263. * @param maxAgentRadius the maximum radius an agent can have
  62264. * @param scene to attach the crowd to
  62265. * @returns the crowd you can add agents to
  62266. */
  62267. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62268. /**
  62269. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62270. * You can attach anything to that node. The node position is updated in the scene update tick.
  62271. * @param pos world position that will be constrained by the navigation mesh
  62272. * @param parameters agent parameters
  62273. * @param transform hooked to the agent that will be update by the scene
  62274. * @returns agent index
  62275. */
  62276. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62277. /**
  62278. * Returns the agent position in world space
  62279. * @param index agent index returned by addAgent
  62280. * @returns world space position
  62281. */
  62282. getAgentPosition(index: number): Vector3;
  62283. /**
  62284. * Returns the agent velocity in world space
  62285. * @param index agent index returned by addAgent
  62286. * @returns world space velocity
  62287. */
  62288. getAgentVelocity(index: number): Vector3;
  62289. /**
  62290. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62291. * @param index agent index returned by addAgent
  62292. * @param destination targeted world position
  62293. */
  62294. agentGoto(index: number, destination: Vector3): void;
  62295. /**
  62296. * Teleport the agent to a new position
  62297. * @param index agent index returned by addAgent
  62298. * @param destination targeted world position
  62299. */
  62300. agentTeleport(index: number, destination: Vector3): void;
  62301. /**
  62302. * Update agent parameters
  62303. * @param index agent index returned by addAgent
  62304. * @param parameters agent parameters
  62305. */
  62306. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62307. /**
  62308. * remove a particular agent previously created
  62309. * @param index agent index returned by addAgent
  62310. */
  62311. removeAgent(index: number): void;
  62312. /**
  62313. * get the list of all agents attached to this crowd
  62314. * @returns list of agent indices
  62315. */
  62316. getAgents(): number[];
  62317. /**
  62318. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62319. * @param deltaTime in seconds
  62320. */
  62321. update(deltaTime: number): void;
  62322. /**
  62323. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62324. * The queries will try to find a solution within those bounds
  62325. * default is (1,1,1)
  62326. * @param extent x,y,z value that define the extent around the queries point of reference
  62327. */
  62328. setDefaultQueryExtent(extent: Vector3): void;
  62329. /**
  62330. * Get the Bounding box extent specified by setDefaultQueryExtent
  62331. * @returns the box extent values
  62332. */
  62333. getDefaultQueryExtent(): Vector3;
  62334. /**
  62335. * Release all resources
  62336. */
  62337. dispose(): void;
  62338. }
  62339. }
  62340. declare module BABYLON {
  62341. /**
  62342. * Class used to enable access to IndexedDB
  62343. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62344. */
  62345. export class Database implements IOfflineProvider {
  62346. private _callbackManifestChecked;
  62347. private _currentSceneUrl;
  62348. private _db;
  62349. private _enableSceneOffline;
  62350. private _enableTexturesOffline;
  62351. private _manifestVersionFound;
  62352. private _mustUpdateRessources;
  62353. private _hasReachedQuota;
  62354. private _isSupported;
  62355. private _idbFactory;
  62356. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62357. private static IsUASupportingBlobStorage;
  62358. /**
  62359. * Gets a boolean indicating if Database storate is enabled (off by default)
  62360. */
  62361. static IDBStorageEnabled: boolean;
  62362. /**
  62363. * Gets a boolean indicating if scene must be saved in the database
  62364. */
  62365. get enableSceneOffline(): boolean;
  62366. /**
  62367. * Gets a boolean indicating if textures must be saved in the database
  62368. */
  62369. get enableTexturesOffline(): boolean;
  62370. /**
  62371. * Creates a new Database
  62372. * @param urlToScene defines the url to load the scene
  62373. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62374. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62375. */
  62376. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62377. private static _ParseURL;
  62378. private static _ReturnFullUrlLocation;
  62379. private _checkManifestFile;
  62380. /**
  62381. * Open the database and make it available
  62382. * @param successCallback defines the callback to call on success
  62383. * @param errorCallback defines the callback to call on error
  62384. */
  62385. open(successCallback: () => void, errorCallback: () => void): void;
  62386. /**
  62387. * Loads an image from the database
  62388. * @param url defines the url to load from
  62389. * @param image defines the target DOM image
  62390. */
  62391. loadImage(url: string, image: HTMLImageElement): void;
  62392. private _loadImageFromDBAsync;
  62393. private _saveImageIntoDBAsync;
  62394. private _checkVersionFromDB;
  62395. private _loadVersionFromDBAsync;
  62396. private _saveVersionIntoDBAsync;
  62397. /**
  62398. * Loads a file from database
  62399. * @param url defines the URL to load from
  62400. * @param sceneLoaded defines a callback to call on success
  62401. * @param progressCallBack defines a callback to call when progress changed
  62402. * @param errorCallback defines a callback to call on error
  62403. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62404. */
  62405. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62406. private _loadFileAsync;
  62407. private _saveFileAsync;
  62408. /**
  62409. * Validates if xhr data is correct
  62410. * @param xhr defines the request to validate
  62411. * @param dataType defines the expected data type
  62412. * @returns true if data is correct
  62413. */
  62414. private static _ValidateXHRData;
  62415. }
  62416. }
  62417. declare module BABYLON {
  62418. /** @hidden */
  62419. export var gpuUpdateParticlesPixelShader: {
  62420. name: string;
  62421. shader: string;
  62422. };
  62423. }
  62424. declare module BABYLON {
  62425. /** @hidden */
  62426. export var gpuUpdateParticlesVertexShader: {
  62427. name: string;
  62428. shader: string;
  62429. };
  62430. }
  62431. declare module BABYLON {
  62432. /** @hidden */
  62433. export var clipPlaneFragmentDeclaration2: {
  62434. name: string;
  62435. shader: string;
  62436. };
  62437. }
  62438. declare module BABYLON {
  62439. /** @hidden */
  62440. export var gpuRenderParticlesPixelShader: {
  62441. name: string;
  62442. shader: string;
  62443. };
  62444. }
  62445. declare module BABYLON {
  62446. /** @hidden */
  62447. export var clipPlaneVertexDeclaration2: {
  62448. name: string;
  62449. shader: string;
  62450. };
  62451. }
  62452. declare module BABYLON {
  62453. /** @hidden */
  62454. export var gpuRenderParticlesVertexShader: {
  62455. name: string;
  62456. shader: string;
  62457. };
  62458. }
  62459. declare module BABYLON {
  62460. /**
  62461. * This represents a GPU particle system in Babylon
  62462. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62463. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62464. */
  62465. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62466. /**
  62467. * The layer mask we are rendering the particles through.
  62468. */
  62469. layerMask: number;
  62470. private _capacity;
  62471. private _activeCount;
  62472. private _currentActiveCount;
  62473. private _accumulatedCount;
  62474. private _renderEffect;
  62475. private _updateEffect;
  62476. private _buffer0;
  62477. private _buffer1;
  62478. private _spriteBuffer;
  62479. private _updateVAO;
  62480. private _renderVAO;
  62481. private _targetIndex;
  62482. private _sourceBuffer;
  62483. private _targetBuffer;
  62484. private _engine;
  62485. private _currentRenderId;
  62486. private _started;
  62487. private _stopped;
  62488. private _timeDelta;
  62489. private _randomTexture;
  62490. private _randomTexture2;
  62491. private _attributesStrideSize;
  62492. private _updateEffectOptions;
  62493. private _randomTextureSize;
  62494. private _actualFrame;
  62495. private readonly _rawTextureWidth;
  62496. /**
  62497. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62498. */
  62499. static get IsSupported(): boolean;
  62500. /**
  62501. * An event triggered when the system is disposed.
  62502. */
  62503. onDisposeObservable: Observable<GPUParticleSystem>;
  62504. /**
  62505. * Gets the maximum number of particles active at the same time.
  62506. * @returns The max number of active particles.
  62507. */
  62508. getCapacity(): number;
  62509. /**
  62510. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62511. * to override the particles.
  62512. */
  62513. forceDepthWrite: boolean;
  62514. /**
  62515. * Gets or set the number of active particles
  62516. */
  62517. get activeParticleCount(): number;
  62518. set activeParticleCount(value: number);
  62519. private _preWarmDone;
  62520. /**
  62521. * Is this system ready to be used/rendered
  62522. * @return true if the system is ready
  62523. */
  62524. isReady(): boolean;
  62525. /**
  62526. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62527. * @returns True if it has been started, otherwise false.
  62528. */
  62529. isStarted(): boolean;
  62530. /**
  62531. * Starts the particle system and begins to emit
  62532. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62533. */
  62534. start(delay?: number): void;
  62535. /**
  62536. * Stops the particle system.
  62537. */
  62538. stop(): void;
  62539. /**
  62540. * Remove all active particles
  62541. */
  62542. reset(): void;
  62543. /**
  62544. * Returns the string "GPUParticleSystem"
  62545. * @returns a string containing the class name
  62546. */
  62547. getClassName(): string;
  62548. private _colorGradientsTexture;
  62549. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62550. /**
  62551. * Adds a new color gradient
  62552. * @param gradient defines the gradient to use (between 0 and 1)
  62553. * @param color1 defines the color to affect to the specified gradient
  62554. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62555. * @returns the current particle system
  62556. */
  62557. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62558. /**
  62559. * Remove a specific color gradient
  62560. * @param gradient defines the gradient to remove
  62561. * @returns the current particle system
  62562. */
  62563. removeColorGradient(gradient: number): GPUParticleSystem;
  62564. private _angularSpeedGradientsTexture;
  62565. private _sizeGradientsTexture;
  62566. private _velocityGradientsTexture;
  62567. private _limitVelocityGradientsTexture;
  62568. private _dragGradientsTexture;
  62569. private _addFactorGradient;
  62570. /**
  62571. * Adds a new size gradient
  62572. * @param gradient defines the gradient to use (between 0 and 1)
  62573. * @param factor defines the size factor to affect to the specified gradient
  62574. * @returns the current particle system
  62575. */
  62576. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62577. /**
  62578. * Remove a specific size gradient
  62579. * @param gradient defines the gradient to remove
  62580. * @returns the current particle system
  62581. */
  62582. removeSizeGradient(gradient: number): GPUParticleSystem;
  62583. /**
  62584. * Adds a new angular speed gradient
  62585. * @param gradient defines the gradient to use (between 0 and 1)
  62586. * @param factor defines the angular speed to affect to the specified gradient
  62587. * @returns the current particle system
  62588. */
  62589. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62590. /**
  62591. * Remove a specific angular speed gradient
  62592. * @param gradient defines the gradient to remove
  62593. * @returns the current particle system
  62594. */
  62595. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62596. /**
  62597. * Adds a new velocity gradient
  62598. * @param gradient defines the gradient to use (between 0 and 1)
  62599. * @param factor defines the velocity to affect to the specified gradient
  62600. * @returns the current particle system
  62601. */
  62602. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62603. /**
  62604. * Remove a specific velocity gradient
  62605. * @param gradient defines the gradient to remove
  62606. * @returns the current particle system
  62607. */
  62608. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62609. /**
  62610. * Adds a new limit velocity gradient
  62611. * @param gradient defines the gradient to use (between 0 and 1)
  62612. * @param factor defines the limit velocity value to affect to the specified gradient
  62613. * @returns the current particle system
  62614. */
  62615. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62616. /**
  62617. * Remove a specific limit velocity gradient
  62618. * @param gradient defines the gradient to remove
  62619. * @returns the current particle system
  62620. */
  62621. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62622. /**
  62623. * Adds a new drag gradient
  62624. * @param gradient defines the gradient to use (between 0 and 1)
  62625. * @param factor defines the drag value to affect to the specified gradient
  62626. * @returns the current particle system
  62627. */
  62628. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62629. /**
  62630. * Remove a specific drag gradient
  62631. * @param gradient defines the gradient to remove
  62632. * @returns the current particle system
  62633. */
  62634. removeDragGradient(gradient: number): GPUParticleSystem;
  62635. /**
  62636. * Not supported by GPUParticleSystem
  62637. * @param gradient defines the gradient to use (between 0 and 1)
  62638. * @param factor defines the emit rate value to affect to the specified gradient
  62639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62640. * @returns the current particle system
  62641. */
  62642. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62643. /**
  62644. * Not supported by GPUParticleSystem
  62645. * @param gradient defines the gradient to remove
  62646. * @returns the current particle system
  62647. */
  62648. removeEmitRateGradient(gradient: number): IParticleSystem;
  62649. /**
  62650. * Not supported by GPUParticleSystem
  62651. * @param gradient defines the gradient to use (between 0 and 1)
  62652. * @param factor defines the start size value to affect to the specified gradient
  62653. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62654. * @returns the current particle system
  62655. */
  62656. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62657. /**
  62658. * Not supported by GPUParticleSystem
  62659. * @param gradient defines the gradient to remove
  62660. * @returns the current particle system
  62661. */
  62662. removeStartSizeGradient(gradient: number): IParticleSystem;
  62663. /**
  62664. * Not supported by GPUParticleSystem
  62665. * @param gradient defines the gradient to use (between 0 and 1)
  62666. * @param min defines the color remap minimal range
  62667. * @param max defines the color remap maximal range
  62668. * @returns the current particle system
  62669. */
  62670. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62671. /**
  62672. * Not supported by GPUParticleSystem
  62673. * @param gradient defines the gradient to remove
  62674. * @returns the current particle system
  62675. */
  62676. removeColorRemapGradient(): IParticleSystem;
  62677. /**
  62678. * Not supported by GPUParticleSystem
  62679. * @param gradient defines the gradient to use (between 0 and 1)
  62680. * @param min defines the alpha remap minimal range
  62681. * @param max defines the alpha remap maximal range
  62682. * @returns the current particle system
  62683. */
  62684. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62685. /**
  62686. * Not supported by GPUParticleSystem
  62687. * @param gradient defines the gradient to remove
  62688. * @returns the current particle system
  62689. */
  62690. removeAlphaRemapGradient(): IParticleSystem;
  62691. /**
  62692. * Not supported by GPUParticleSystem
  62693. * @param gradient defines the gradient to use (between 0 and 1)
  62694. * @param color defines the color to affect to the specified gradient
  62695. * @returns the current particle system
  62696. */
  62697. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62698. /**
  62699. * Not supported by GPUParticleSystem
  62700. * @param gradient defines the gradient to remove
  62701. * @returns the current particle system
  62702. */
  62703. removeRampGradient(): IParticleSystem;
  62704. /**
  62705. * Not supported by GPUParticleSystem
  62706. * @returns the list of ramp gradients
  62707. */
  62708. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62709. /**
  62710. * Not supported by GPUParticleSystem
  62711. * Gets or sets a boolean indicating that ramp gradients must be used
  62712. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62713. */
  62714. get useRampGradients(): boolean;
  62715. set useRampGradients(value: boolean);
  62716. /**
  62717. * Not supported by GPUParticleSystem
  62718. * @param gradient defines the gradient to use (between 0 and 1)
  62719. * @param factor defines the life time factor to affect to the specified gradient
  62720. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62721. * @returns the current particle system
  62722. */
  62723. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62724. /**
  62725. * Not supported by GPUParticleSystem
  62726. * @param gradient defines the gradient to remove
  62727. * @returns the current particle system
  62728. */
  62729. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62730. /**
  62731. * Instantiates a GPU particle system.
  62732. * 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.
  62733. * @param name The name of the particle system
  62734. * @param options The options used to create the system
  62735. * @param scene The scene the particle system belongs to
  62736. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62737. */
  62738. constructor(name: string, options: Partial<{
  62739. capacity: number;
  62740. randomTextureSize: number;
  62741. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62742. protected _reset(): void;
  62743. private _createUpdateVAO;
  62744. private _createRenderVAO;
  62745. private _initialize;
  62746. /** @hidden */
  62747. _recreateUpdateEffect(): void;
  62748. /** @hidden */
  62749. _recreateRenderEffect(): void;
  62750. /**
  62751. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62752. * @param preWarm defines if we are in the pre-warmimg phase
  62753. */
  62754. animate(preWarm?: boolean): void;
  62755. private _createFactorGradientTexture;
  62756. private _createSizeGradientTexture;
  62757. private _createAngularSpeedGradientTexture;
  62758. private _createVelocityGradientTexture;
  62759. private _createLimitVelocityGradientTexture;
  62760. private _createDragGradientTexture;
  62761. private _createColorGradientTexture;
  62762. /**
  62763. * Renders the particle system in its current state
  62764. * @param preWarm defines if the system should only update the particles but not render them
  62765. * @returns the current number of particles
  62766. */
  62767. render(preWarm?: boolean): number;
  62768. /**
  62769. * Rebuilds the particle system
  62770. */
  62771. rebuild(): void;
  62772. private _releaseBuffers;
  62773. private _releaseVAOs;
  62774. /**
  62775. * Disposes the particle system and free the associated resources
  62776. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62777. */
  62778. dispose(disposeTexture?: boolean): void;
  62779. /**
  62780. * Clones the particle system.
  62781. * @param name The name of the cloned object
  62782. * @param newEmitter The new emitter to use
  62783. * @returns the cloned particle system
  62784. */
  62785. clone(name: string, newEmitter: any): GPUParticleSystem;
  62786. /**
  62787. * Serializes the particle system to a JSON object.
  62788. * @returns the JSON object
  62789. */
  62790. serialize(): any;
  62791. /**
  62792. * Parses a JSON object to create a GPU particle system.
  62793. * @param parsedParticleSystem The JSON object to parse
  62794. * @param scene The scene to create the particle system in
  62795. * @param rootUrl The root url to use to load external dependencies like texture
  62796. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62797. * @returns the parsed GPU particle system
  62798. */
  62799. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62800. }
  62801. }
  62802. declare module BABYLON {
  62803. /**
  62804. * Represents a set of particle systems working together to create a specific effect
  62805. */
  62806. export class ParticleSystemSet implements IDisposable {
  62807. /**
  62808. * Gets or sets base Assets URL
  62809. */
  62810. static BaseAssetsUrl: string;
  62811. private _emitterCreationOptions;
  62812. private _emitterNode;
  62813. /**
  62814. * Gets the particle system list
  62815. */
  62816. systems: IParticleSystem[];
  62817. /**
  62818. * Gets the emitter node used with this set
  62819. */
  62820. get emitterNode(): Nullable<TransformNode>;
  62821. /**
  62822. * Creates a new emitter mesh as a sphere
  62823. * @param options defines the options used to create the sphere
  62824. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62825. * @param scene defines the hosting scene
  62826. */
  62827. setEmitterAsSphere(options: {
  62828. diameter: number;
  62829. segments: number;
  62830. color: Color3;
  62831. }, renderingGroupId: number, scene: Scene): void;
  62832. /**
  62833. * Starts all particle systems of the set
  62834. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62835. */
  62836. start(emitter?: AbstractMesh): void;
  62837. /**
  62838. * Release all associated resources
  62839. */
  62840. dispose(): void;
  62841. /**
  62842. * Serialize the set into a JSON compatible object
  62843. * @returns a JSON compatible representation of the set
  62844. */
  62845. serialize(): any;
  62846. /**
  62847. * Parse a new ParticleSystemSet from a serialized source
  62848. * @param data defines a JSON compatible representation of the set
  62849. * @param scene defines the hosting scene
  62850. * @param gpu defines if we want GPU particles or CPU particles
  62851. * @returns a new ParticleSystemSet
  62852. */
  62853. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62854. }
  62855. }
  62856. declare module BABYLON {
  62857. /**
  62858. * This class is made for on one-liner static method to help creating particle system set.
  62859. */
  62860. export class ParticleHelper {
  62861. /**
  62862. * Gets or sets base Assets URL
  62863. */
  62864. static BaseAssetsUrl: string;
  62865. /**
  62866. * Create a default particle system that you can tweak
  62867. * @param emitter defines the emitter to use
  62868. * @param capacity defines the system capacity (default is 500 particles)
  62869. * @param scene defines the hosting scene
  62870. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62871. * @returns the new Particle system
  62872. */
  62873. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62874. /**
  62875. * This is the main static method (one-liner) of this helper to create different particle systems
  62876. * @param type This string represents the type to the particle system to create
  62877. * @param scene The scene where the particle system should live
  62878. * @param gpu If the system will use gpu
  62879. * @returns the ParticleSystemSet created
  62880. */
  62881. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62882. /**
  62883. * Static function used to export a particle system to a ParticleSystemSet variable.
  62884. * Please note that the emitter shape is not exported
  62885. * @param systems defines the particle systems to export
  62886. * @returns the created particle system set
  62887. */
  62888. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62889. }
  62890. }
  62891. declare module BABYLON {
  62892. interface Engine {
  62893. /**
  62894. * Create an effect to use with particle systems.
  62895. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62896. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62897. * @param uniformsNames defines a list of attribute names
  62898. * @param samplers defines an array of string used to represent textures
  62899. * @param defines defines the string containing the defines to use to compile the shaders
  62900. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62901. * @param onCompiled defines a function to call when the effect creation is successful
  62902. * @param onError defines a function to call when the effect creation has failed
  62903. * @returns the new Effect
  62904. */
  62905. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62906. }
  62907. interface Mesh {
  62908. /**
  62909. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62910. * @returns an array of IParticleSystem
  62911. */
  62912. getEmittedParticleSystems(): IParticleSystem[];
  62913. /**
  62914. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62915. * @returns an array of IParticleSystem
  62916. */
  62917. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62918. }
  62919. /**
  62920. * @hidden
  62921. */
  62922. export var _IDoNeedToBeInTheBuild: number;
  62923. }
  62924. declare module BABYLON {
  62925. /** Defines the 4 color options */
  62926. export enum PointColor {
  62927. /** color value */
  62928. Color = 2,
  62929. /** uv value */
  62930. UV = 1,
  62931. /** random value */
  62932. Random = 0,
  62933. /** stated value */
  62934. Stated = 3
  62935. }
  62936. /**
  62937. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62938. * 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.
  62939. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62940. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62941. *
  62942. * Full documentation here : TO BE ENTERED
  62943. */
  62944. export class PointsCloudSystem implements IDisposable {
  62945. /**
  62946. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62947. * Example : var p = SPS.particles[i];
  62948. */
  62949. particles: CloudPoint[];
  62950. /**
  62951. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62952. */
  62953. nbParticles: number;
  62954. /**
  62955. * This a counter for your own usage. It's not set by any SPS functions.
  62956. */
  62957. counter: number;
  62958. /**
  62959. * The PCS name. This name is also given to the underlying mesh.
  62960. */
  62961. name: string;
  62962. /**
  62963. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62964. */
  62965. mesh: Mesh;
  62966. /**
  62967. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62968. * Please read :
  62969. */
  62970. vars: any;
  62971. /**
  62972. * @hidden
  62973. */
  62974. _size: number;
  62975. private _scene;
  62976. private _promises;
  62977. private _positions;
  62978. private _indices;
  62979. private _normals;
  62980. private _colors;
  62981. private _uvs;
  62982. private _indices32;
  62983. private _positions32;
  62984. private _colors32;
  62985. private _uvs32;
  62986. private _updatable;
  62987. private _isVisibilityBoxLocked;
  62988. private _alwaysVisible;
  62989. private _groups;
  62990. private _groupCounter;
  62991. private _computeParticleColor;
  62992. private _computeParticleTexture;
  62993. private _computeParticleRotation;
  62994. private _computeBoundingBox;
  62995. private _isReady;
  62996. /**
  62997. * Creates a PCS (Points Cloud System) object
  62998. * @param name (String) is the PCS name, this will be the underlying mesh name
  62999. * @param pointSize (number) is the size for each point
  63000. * @param scene (Scene) is the scene in which the PCS is added
  63001. * @param options defines the options of the PCS e.g.
  63002. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63003. */
  63004. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63005. updatable?: boolean;
  63006. });
  63007. /**
  63008. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63009. * If no points were added to the PCS, the returned mesh is just a single point.
  63010. * @returns a promise for the created mesh
  63011. */
  63012. buildMeshAsync(): Promise<Mesh>;
  63013. /**
  63014. * @hidden
  63015. */
  63016. private _buildMesh;
  63017. private _addParticle;
  63018. private _randomUnitVector;
  63019. private _getColorIndicesForCoord;
  63020. private _setPointsColorOrUV;
  63021. private _colorFromTexture;
  63022. private _calculateDensity;
  63023. /**
  63024. * Adds points to the PCS in random positions within a unit sphere
  63025. * @param nb (positive integer) the number of particles to be created from this model
  63026. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63027. * @returns the number of groups in the system
  63028. */
  63029. addPoints(nb: number, pointFunction?: any): number;
  63030. /**
  63031. * Adds points to the PCS from the surface of the model shape
  63032. * @param mesh is any Mesh object that will be used as a surface model for the points
  63033. * @param nb (positive integer) the number of particles to be created from this model
  63034. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63035. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63036. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63037. * @returns the number of groups in the system
  63038. */
  63039. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63040. /**
  63041. * Adds points to the PCS inside the model shape
  63042. * @param mesh is any Mesh object that will be used as a surface model for the points
  63043. * @param nb (positive integer) the number of particles to be created from this model
  63044. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63045. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63046. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63047. * @returns the number of groups in the system
  63048. */
  63049. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63050. /**
  63051. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63052. * This method calls `updateParticle()` for each particle of the SPS.
  63053. * For an animated SPS, it is usually called within the render loop.
  63054. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63055. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63056. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63057. * @returns the PCS.
  63058. */
  63059. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63060. /**
  63061. * Disposes the PCS.
  63062. */
  63063. dispose(): void;
  63064. /**
  63065. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63066. * doc :
  63067. * @returns the PCS.
  63068. */
  63069. refreshVisibleSize(): PointsCloudSystem;
  63070. /**
  63071. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63072. * @param size the size (float) of the visibility box
  63073. * note : this doesn't lock the PCS mesh bounding box.
  63074. * doc :
  63075. */
  63076. setVisibilityBox(size: number): void;
  63077. /**
  63078. * Gets whether the PCS is always visible or not
  63079. * doc :
  63080. */
  63081. get isAlwaysVisible(): boolean;
  63082. /**
  63083. * Sets the PCS as always visible or not
  63084. * doc :
  63085. */
  63086. set isAlwaysVisible(val: boolean);
  63087. /**
  63088. * Tells to `setParticles()` to compute the particle rotations or not
  63089. * Default value : false. The PCS is faster when it's set to false
  63090. * Note : particle rotations are only applied to parent particles
  63091. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63092. */
  63093. set computeParticleRotation(val: boolean);
  63094. /**
  63095. * Tells to `setParticles()` to compute the particle colors or not.
  63096. * Default value : true. The PCS is faster when it's set to false.
  63097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63098. */
  63099. set computeParticleColor(val: boolean);
  63100. set computeParticleTexture(val: boolean);
  63101. /**
  63102. * Gets if `setParticles()` computes the particle colors or not.
  63103. * Default value : false. The PCS is faster when it's set to false.
  63104. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63105. */
  63106. get computeParticleColor(): boolean;
  63107. /**
  63108. * Gets if `setParticles()` computes the particle textures or not.
  63109. * Default value : false. The PCS is faster when it's set to false.
  63110. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63111. */
  63112. get computeParticleTexture(): boolean;
  63113. /**
  63114. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63115. */
  63116. set computeBoundingBox(val: boolean);
  63117. /**
  63118. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63119. */
  63120. get computeBoundingBox(): boolean;
  63121. /**
  63122. * This function does nothing. It may be overwritten to set all the particle first values.
  63123. * The PCS doesn't call this function, you may have to call it by your own.
  63124. * doc :
  63125. */
  63126. initParticles(): void;
  63127. /**
  63128. * This function does nothing. It may be overwritten to recycle a particle
  63129. * The PCS doesn't call this function, you can to call it
  63130. * doc :
  63131. * @param particle The particle to recycle
  63132. * @returns the recycled particle
  63133. */
  63134. recycleParticle(particle: CloudPoint): CloudPoint;
  63135. /**
  63136. * Updates a particle : this function should be overwritten by the user.
  63137. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63138. * doc :
  63139. * @example : just set a particle position or velocity and recycle conditions
  63140. * @param particle The particle to update
  63141. * @returns the updated particle
  63142. */
  63143. updateParticle(particle: CloudPoint): CloudPoint;
  63144. /**
  63145. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63146. * This does nothing and may be overwritten by the user.
  63147. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63148. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63149. * @param update the boolean update value actually passed to setParticles()
  63150. */
  63151. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63152. /**
  63153. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63154. * This will be passed three parameters.
  63155. * This does nothing and may be overwritten by the user.
  63156. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63157. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63158. * @param update the boolean update value actually passed to setParticles()
  63159. */
  63160. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63161. }
  63162. }
  63163. declare module BABYLON {
  63164. /**
  63165. * Represents one particle of a points cloud system.
  63166. */
  63167. export class CloudPoint {
  63168. /**
  63169. * particle global index
  63170. */
  63171. idx: number;
  63172. /**
  63173. * The color of the particle
  63174. */
  63175. color: Nullable<Color4>;
  63176. /**
  63177. * The world space position of the particle.
  63178. */
  63179. position: Vector3;
  63180. /**
  63181. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63182. */
  63183. rotation: Vector3;
  63184. /**
  63185. * The world space rotation quaternion of the particle.
  63186. */
  63187. rotationQuaternion: Nullable<Quaternion>;
  63188. /**
  63189. * The uv of the particle.
  63190. */
  63191. uv: Nullable<Vector2>;
  63192. /**
  63193. * The current speed of the particle.
  63194. */
  63195. velocity: Vector3;
  63196. /**
  63197. * The pivot point in the particle local space.
  63198. */
  63199. pivot: Vector3;
  63200. /**
  63201. * Must the particle be translated from its pivot point in its local space ?
  63202. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63203. * Default : false
  63204. */
  63205. translateFromPivot: boolean;
  63206. /**
  63207. * Index of this particle in the global "positions" array (Internal use)
  63208. * @hidden
  63209. */
  63210. _pos: number;
  63211. /**
  63212. * @hidden Index of this particle in the global "indices" array (Internal use)
  63213. */
  63214. _ind: number;
  63215. /**
  63216. * Group this particle belongs to
  63217. */
  63218. _group: PointsGroup;
  63219. /**
  63220. * Group id of this particle
  63221. */
  63222. groupId: number;
  63223. /**
  63224. * Index of the particle in its group id (Internal use)
  63225. */
  63226. idxInGroup: number;
  63227. /**
  63228. * @hidden Particle BoundingInfo object (Internal use)
  63229. */
  63230. _boundingInfo: BoundingInfo;
  63231. /**
  63232. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63233. */
  63234. _pcs: PointsCloudSystem;
  63235. /**
  63236. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63237. */
  63238. _stillInvisible: boolean;
  63239. /**
  63240. * @hidden Last computed particle rotation matrix
  63241. */
  63242. _rotationMatrix: number[];
  63243. /**
  63244. * Parent particle Id, if any.
  63245. * Default null.
  63246. */
  63247. parentId: Nullable<number>;
  63248. /**
  63249. * @hidden Internal global position in the PCS.
  63250. */
  63251. _globalPosition: Vector3;
  63252. /**
  63253. * Creates a Point Cloud object.
  63254. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63255. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63256. * @param group (PointsGroup) is the group the particle belongs to
  63257. * @param groupId (integer) is the group identifier in the PCS.
  63258. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63259. * @param pcs defines the PCS it is associated to
  63260. */
  63261. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63262. /**
  63263. * get point size
  63264. */
  63265. get size(): Vector3;
  63266. /**
  63267. * Set point size
  63268. */
  63269. set size(scale: Vector3);
  63270. /**
  63271. * Legacy support, changed quaternion to rotationQuaternion
  63272. */
  63273. get quaternion(): Nullable<Quaternion>;
  63274. /**
  63275. * Legacy support, changed quaternion to rotationQuaternion
  63276. */
  63277. set quaternion(q: Nullable<Quaternion>);
  63278. /**
  63279. * Returns a boolean. True if the particle intersects a mesh, else false
  63280. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63281. * @param target is the object (point or mesh) what the intersection is computed against
  63282. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63283. * @returns true if it intersects
  63284. */
  63285. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63286. /**
  63287. * get the rotation matrix of the particle
  63288. * @hidden
  63289. */
  63290. getRotationMatrix(m: Matrix): void;
  63291. }
  63292. /**
  63293. * Represents a group of points in a points cloud system
  63294. * * PCS internal tool, don't use it manually.
  63295. */
  63296. export class PointsGroup {
  63297. /**
  63298. * The group id
  63299. * @hidden
  63300. */
  63301. groupID: number;
  63302. /**
  63303. * image data for group (internal use)
  63304. * @hidden
  63305. */
  63306. _groupImageData: Nullable<ArrayBufferView>;
  63307. /**
  63308. * Image Width (internal use)
  63309. * @hidden
  63310. */
  63311. _groupImgWidth: number;
  63312. /**
  63313. * Image Height (internal use)
  63314. * @hidden
  63315. */
  63316. _groupImgHeight: number;
  63317. /**
  63318. * Custom position function (internal use)
  63319. * @hidden
  63320. */
  63321. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63322. /**
  63323. * density per facet for surface points
  63324. * @hidden
  63325. */
  63326. _groupDensity: number[];
  63327. /**
  63328. * Only when points are colored by texture carries pointer to texture list array
  63329. * @hidden
  63330. */
  63331. _textureNb: number;
  63332. /**
  63333. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63334. * PCS internal tool, don't use it manually.
  63335. * @hidden
  63336. */
  63337. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63338. }
  63339. }
  63340. declare module BABYLON {
  63341. interface Scene {
  63342. /** @hidden (Backing field) */
  63343. _physicsEngine: Nullable<IPhysicsEngine>;
  63344. /** @hidden */
  63345. _physicsTimeAccumulator: number;
  63346. /**
  63347. * Gets the current physics engine
  63348. * @returns a IPhysicsEngine or null if none attached
  63349. */
  63350. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63351. /**
  63352. * Enables physics to the current scene
  63353. * @param gravity defines the scene's gravity for the physics engine
  63354. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63355. * @return a boolean indicating if the physics engine was initialized
  63356. */
  63357. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63358. /**
  63359. * Disables and disposes the physics engine associated with the scene
  63360. */
  63361. disablePhysicsEngine(): void;
  63362. /**
  63363. * Gets a boolean indicating if there is an active physics engine
  63364. * @returns a boolean indicating if there is an active physics engine
  63365. */
  63366. isPhysicsEnabled(): boolean;
  63367. /**
  63368. * Deletes a physics compound impostor
  63369. * @param compound defines the compound to delete
  63370. */
  63371. deleteCompoundImpostor(compound: any): void;
  63372. /**
  63373. * An event triggered when physic simulation is about to be run
  63374. */
  63375. onBeforePhysicsObservable: Observable<Scene>;
  63376. /**
  63377. * An event triggered when physic simulation has been done
  63378. */
  63379. onAfterPhysicsObservable: Observable<Scene>;
  63380. }
  63381. interface AbstractMesh {
  63382. /** @hidden */
  63383. _physicsImpostor: Nullable<PhysicsImpostor>;
  63384. /**
  63385. * Gets or sets impostor used for physic simulation
  63386. * @see http://doc.babylonjs.com/features/physics_engine
  63387. */
  63388. physicsImpostor: Nullable<PhysicsImpostor>;
  63389. /**
  63390. * Gets the current physics impostor
  63391. * @see http://doc.babylonjs.com/features/physics_engine
  63392. * @returns a physics impostor or null
  63393. */
  63394. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63395. /** Apply a physic impulse to the mesh
  63396. * @param force defines the force to apply
  63397. * @param contactPoint defines where to apply the force
  63398. * @returns the current mesh
  63399. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63400. */
  63401. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63402. /**
  63403. * Creates a physic joint between two meshes
  63404. * @param otherMesh defines the other mesh to use
  63405. * @param pivot1 defines the pivot to use on this mesh
  63406. * @param pivot2 defines the pivot to use on the other mesh
  63407. * @param options defines additional options (can be plugin dependent)
  63408. * @returns the current mesh
  63409. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63410. */
  63411. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63412. /** @hidden */
  63413. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63414. }
  63415. /**
  63416. * Defines the physics engine scene component responsible to manage a physics engine
  63417. */
  63418. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63419. /**
  63420. * The component name helpful to identify the component in the list of scene components.
  63421. */
  63422. readonly name: string;
  63423. /**
  63424. * The scene the component belongs to.
  63425. */
  63426. scene: Scene;
  63427. /**
  63428. * Creates a new instance of the component for the given scene
  63429. * @param scene Defines the scene to register the component in
  63430. */
  63431. constructor(scene: Scene);
  63432. /**
  63433. * Registers the component in a given scene
  63434. */
  63435. register(): void;
  63436. /**
  63437. * Rebuilds the elements related to this component in case of
  63438. * context lost for instance.
  63439. */
  63440. rebuild(): void;
  63441. /**
  63442. * Disposes the component and the associated ressources
  63443. */
  63444. dispose(): void;
  63445. }
  63446. }
  63447. declare module BABYLON {
  63448. /**
  63449. * A helper for physics simulations
  63450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63451. */
  63452. export class PhysicsHelper {
  63453. private _scene;
  63454. private _physicsEngine;
  63455. /**
  63456. * Initializes the Physics helper
  63457. * @param scene Babylon.js scene
  63458. */
  63459. constructor(scene: Scene);
  63460. /**
  63461. * Applies a radial explosion impulse
  63462. * @param origin the origin of the explosion
  63463. * @param radiusOrEventOptions the radius or the options of radial explosion
  63464. * @param strength the explosion strength
  63465. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63466. * @returns A physics radial explosion event, or null
  63467. */
  63468. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63469. /**
  63470. * Applies a radial explosion force
  63471. * @param origin the origin of the explosion
  63472. * @param radiusOrEventOptions the radius or the options of radial explosion
  63473. * @param strength the explosion strength
  63474. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63475. * @returns A physics radial explosion event, or null
  63476. */
  63477. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63478. /**
  63479. * Creates a gravitational field
  63480. * @param origin the origin of the explosion
  63481. * @param radiusOrEventOptions the radius or the options of radial explosion
  63482. * @param strength the explosion strength
  63483. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63484. * @returns A physics gravitational field event, or null
  63485. */
  63486. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63487. /**
  63488. * Creates a physics updraft event
  63489. * @param origin the origin of the updraft
  63490. * @param radiusOrEventOptions the radius or the options of the updraft
  63491. * @param strength the strength of the updraft
  63492. * @param height the height of the updraft
  63493. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63494. * @returns A physics updraft event, or null
  63495. */
  63496. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63497. /**
  63498. * Creates a physics vortex event
  63499. * @param origin the of the vortex
  63500. * @param radiusOrEventOptions the radius or the options of the vortex
  63501. * @param strength the strength of the vortex
  63502. * @param height the height of the vortex
  63503. * @returns a Physics vortex event, or null
  63504. * A physics vortex event or null
  63505. */
  63506. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63507. }
  63508. /**
  63509. * Represents a physics radial explosion event
  63510. */
  63511. class PhysicsRadialExplosionEvent {
  63512. private _scene;
  63513. private _options;
  63514. private _sphere;
  63515. private _dataFetched;
  63516. /**
  63517. * Initializes a radial explosioin event
  63518. * @param _scene BabylonJS scene
  63519. * @param _options The options for the vortex event
  63520. */
  63521. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63522. /**
  63523. * Returns the data related to the radial explosion event (sphere).
  63524. * @returns The radial explosion event data
  63525. */
  63526. getData(): PhysicsRadialExplosionEventData;
  63527. /**
  63528. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63529. * @param impostor A physics imposter
  63530. * @param origin the origin of the explosion
  63531. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63532. */
  63533. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63534. /**
  63535. * Triggers affecterd impostors callbacks
  63536. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63537. */
  63538. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63539. /**
  63540. * Disposes the sphere.
  63541. * @param force Specifies if the sphere should be disposed by force
  63542. */
  63543. dispose(force?: boolean): void;
  63544. /*** Helpers ***/
  63545. private _prepareSphere;
  63546. private _intersectsWithSphere;
  63547. }
  63548. /**
  63549. * Represents a gravitational field event
  63550. */
  63551. class PhysicsGravitationalFieldEvent {
  63552. private _physicsHelper;
  63553. private _scene;
  63554. private _origin;
  63555. private _options;
  63556. private _tickCallback;
  63557. private _sphere;
  63558. private _dataFetched;
  63559. /**
  63560. * Initializes the physics gravitational field event
  63561. * @param _physicsHelper A physics helper
  63562. * @param _scene BabylonJS scene
  63563. * @param _origin The origin position of the gravitational field event
  63564. * @param _options The options for the vortex event
  63565. */
  63566. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63567. /**
  63568. * Returns the data related to the gravitational field event (sphere).
  63569. * @returns A gravitational field event
  63570. */
  63571. getData(): PhysicsGravitationalFieldEventData;
  63572. /**
  63573. * Enables the gravitational field.
  63574. */
  63575. enable(): void;
  63576. /**
  63577. * Disables the gravitational field.
  63578. */
  63579. disable(): void;
  63580. /**
  63581. * Disposes the sphere.
  63582. * @param force The force to dispose from the gravitational field event
  63583. */
  63584. dispose(force?: boolean): void;
  63585. private _tick;
  63586. }
  63587. /**
  63588. * Represents a physics updraft event
  63589. */
  63590. class PhysicsUpdraftEvent {
  63591. private _scene;
  63592. private _origin;
  63593. private _options;
  63594. private _physicsEngine;
  63595. private _originTop;
  63596. private _originDirection;
  63597. private _tickCallback;
  63598. private _cylinder;
  63599. private _cylinderPosition;
  63600. private _dataFetched;
  63601. /**
  63602. * Initializes the physics updraft event
  63603. * @param _scene BabylonJS scene
  63604. * @param _origin The origin position of the updraft
  63605. * @param _options The options for the updraft event
  63606. */
  63607. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63608. /**
  63609. * Returns the data related to the updraft event (cylinder).
  63610. * @returns A physics updraft event
  63611. */
  63612. getData(): PhysicsUpdraftEventData;
  63613. /**
  63614. * Enables the updraft.
  63615. */
  63616. enable(): void;
  63617. /**
  63618. * Disables the updraft.
  63619. */
  63620. disable(): void;
  63621. /**
  63622. * Disposes the cylinder.
  63623. * @param force Specifies if the updraft should be disposed by force
  63624. */
  63625. dispose(force?: boolean): void;
  63626. private getImpostorHitData;
  63627. private _tick;
  63628. /*** Helpers ***/
  63629. private _prepareCylinder;
  63630. private _intersectsWithCylinder;
  63631. }
  63632. /**
  63633. * Represents a physics vortex event
  63634. */
  63635. class PhysicsVortexEvent {
  63636. private _scene;
  63637. private _origin;
  63638. private _options;
  63639. private _physicsEngine;
  63640. private _originTop;
  63641. private _tickCallback;
  63642. private _cylinder;
  63643. private _cylinderPosition;
  63644. private _dataFetched;
  63645. /**
  63646. * Initializes the physics vortex event
  63647. * @param _scene The BabylonJS scene
  63648. * @param _origin The origin position of the vortex
  63649. * @param _options The options for the vortex event
  63650. */
  63651. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63652. /**
  63653. * Returns the data related to the vortex event (cylinder).
  63654. * @returns The physics vortex event data
  63655. */
  63656. getData(): PhysicsVortexEventData;
  63657. /**
  63658. * Enables the vortex.
  63659. */
  63660. enable(): void;
  63661. /**
  63662. * Disables the cortex.
  63663. */
  63664. disable(): void;
  63665. /**
  63666. * Disposes the sphere.
  63667. * @param force
  63668. */
  63669. dispose(force?: boolean): void;
  63670. private getImpostorHitData;
  63671. private _tick;
  63672. /*** Helpers ***/
  63673. private _prepareCylinder;
  63674. private _intersectsWithCylinder;
  63675. }
  63676. /**
  63677. * Options fot the radial explosion event
  63678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63679. */
  63680. export class PhysicsRadialExplosionEventOptions {
  63681. /**
  63682. * The radius of the sphere for the radial explosion.
  63683. */
  63684. radius: number;
  63685. /**
  63686. * The strenth of the explosion.
  63687. */
  63688. strength: number;
  63689. /**
  63690. * The strenght of the force in correspondence to the distance of the affected object
  63691. */
  63692. falloff: PhysicsRadialImpulseFalloff;
  63693. /**
  63694. * Sphere options for the radial explosion.
  63695. */
  63696. sphere: {
  63697. segments: number;
  63698. diameter: number;
  63699. };
  63700. /**
  63701. * Sphere options for the radial explosion.
  63702. */
  63703. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63704. }
  63705. /**
  63706. * Options fot the updraft event
  63707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63708. */
  63709. export class PhysicsUpdraftEventOptions {
  63710. /**
  63711. * The radius of the cylinder for the vortex
  63712. */
  63713. radius: number;
  63714. /**
  63715. * The strenth of the updraft.
  63716. */
  63717. strength: number;
  63718. /**
  63719. * The height of the cylinder for the updraft.
  63720. */
  63721. height: number;
  63722. /**
  63723. * The mode for the the updraft.
  63724. */
  63725. updraftMode: PhysicsUpdraftMode;
  63726. }
  63727. /**
  63728. * Options fot the vortex event
  63729. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63730. */
  63731. export class PhysicsVortexEventOptions {
  63732. /**
  63733. * The radius of the cylinder for the vortex
  63734. */
  63735. radius: number;
  63736. /**
  63737. * The strenth of the vortex.
  63738. */
  63739. strength: number;
  63740. /**
  63741. * The height of the cylinder for the vortex.
  63742. */
  63743. height: number;
  63744. /**
  63745. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63746. */
  63747. centripetalForceThreshold: number;
  63748. /**
  63749. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63750. */
  63751. centripetalForceMultiplier: number;
  63752. /**
  63753. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63754. */
  63755. centrifugalForceMultiplier: number;
  63756. /**
  63757. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63758. */
  63759. updraftForceMultiplier: number;
  63760. }
  63761. /**
  63762. * The strenght of the force in correspondence to the distance of the affected object
  63763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63764. */
  63765. export enum PhysicsRadialImpulseFalloff {
  63766. /** Defines that impulse is constant in strength across it's whole radius */
  63767. Constant = 0,
  63768. /** Defines that impulse gets weaker if it's further from the origin */
  63769. Linear = 1
  63770. }
  63771. /**
  63772. * The strength of the force in correspondence to the distance of the affected object
  63773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63774. */
  63775. export enum PhysicsUpdraftMode {
  63776. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63777. Center = 0,
  63778. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63779. Perpendicular = 1
  63780. }
  63781. /**
  63782. * Interface for a physics hit data
  63783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63784. */
  63785. export interface PhysicsHitData {
  63786. /**
  63787. * The force applied at the contact point
  63788. */
  63789. force: Vector3;
  63790. /**
  63791. * The contact point
  63792. */
  63793. contactPoint: Vector3;
  63794. /**
  63795. * The distance from the origin to the contact point
  63796. */
  63797. distanceFromOrigin: number;
  63798. }
  63799. /**
  63800. * Interface for radial explosion event data
  63801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63802. */
  63803. export interface PhysicsRadialExplosionEventData {
  63804. /**
  63805. * A sphere used for the radial explosion event
  63806. */
  63807. sphere: Mesh;
  63808. }
  63809. /**
  63810. * Interface for gravitational field event data
  63811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63812. */
  63813. export interface PhysicsGravitationalFieldEventData {
  63814. /**
  63815. * A sphere mesh used for the gravitational field event
  63816. */
  63817. sphere: Mesh;
  63818. }
  63819. /**
  63820. * Interface for updraft event data
  63821. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63822. */
  63823. export interface PhysicsUpdraftEventData {
  63824. /**
  63825. * A cylinder used for the updraft event
  63826. */
  63827. cylinder: Mesh;
  63828. }
  63829. /**
  63830. * Interface for vortex event data
  63831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63832. */
  63833. export interface PhysicsVortexEventData {
  63834. /**
  63835. * A cylinder used for the vortex event
  63836. */
  63837. cylinder: Mesh;
  63838. }
  63839. /**
  63840. * Interface for an affected physics impostor
  63841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63842. */
  63843. export interface PhysicsAffectedImpostorWithData {
  63844. /**
  63845. * The impostor affected by the effect
  63846. */
  63847. impostor: PhysicsImpostor;
  63848. /**
  63849. * The data about the hit/horce from the explosion
  63850. */
  63851. hitData: PhysicsHitData;
  63852. }
  63853. }
  63854. declare module BABYLON {
  63855. /** @hidden */
  63856. export var blackAndWhitePixelShader: {
  63857. name: string;
  63858. shader: string;
  63859. };
  63860. }
  63861. declare module BABYLON {
  63862. /**
  63863. * Post process used to render in black and white
  63864. */
  63865. export class BlackAndWhitePostProcess extends PostProcess {
  63866. /**
  63867. * Linear about to convert he result to black and white (default: 1)
  63868. */
  63869. degree: number;
  63870. /**
  63871. * Creates a black and white post process
  63872. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63873. * @param name The name of the effect.
  63874. * @param options The required width/height ratio to downsize to before computing the render pass.
  63875. * @param camera The camera to apply the render pass to.
  63876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63877. * @param engine The engine which the post process will be applied. (default: current engine)
  63878. * @param reusable If the post process can be reused on the same frame. (default: false)
  63879. */
  63880. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63881. }
  63882. }
  63883. declare module BABYLON {
  63884. /**
  63885. * This represents a set of one or more post processes in Babylon.
  63886. * A post process can be used to apply a shader to a texture after it is rendered.
  63887. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63888. */
  63889. export class PostProcessRenderEffect {
  63890. private _postProcesses;
  63891. private _getPostProcesses;
  63892. private _singleInstance;
  63893. private _cameras;
  63894. private _indicesForCamera;
  63895. /**
  63896. * Name of the effect
  63897. * @hidden
  63898. */
  63899. _name: string;
  63900. /**
  63901. * Instantiates a post process render effect.
  63902. * A post process can be used to apply a shader to a texture after it is rendered.
  63903. * @param engine The engine the effect is tied to
  63904. * @param name The name of the effect
  63905. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63906. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63907. */
  63908. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63909. /**
  63910. * Checks if all the post processes in the effect are supported.
  63911. */
  63912. get isSupported(): boolean;
  63913. /**
  63914. * Updates the current state of the effect
  63915. * @hidden
  63916. */
  63917. _update(): void;
  63918. /**
  63919. * Attaches the effect on cameras
  63920. * @param cameras The camera to attach to.
  63921. * @hidden
  63922. */
  63923. _attachCameras(cameras: Camera): void;
  63924. /**
  63925. * Attaches the effect on cameras
  63926. * @param cameras The camera to attach to.
  63927. * @hidden
  63928. */
  63929. _attachCameras(cameras: Camera[]): void;
  63930. /**
  63931. * Detaches the effect on cameras
  63932. * @param cameras The camera to detatch from.
  63933. * @hidden
  63934. */
  63935. _detachCameras(cameras: Camera): void;
  63936. /**
  63937. * Detatches the effect on cameras
  63938. * @param cameras The camera to detatch from.
  63939. * @hidden
  63940. */
  63941. _detachCameras(cameras: Camera[]): void;
  63942. /**
  63943. * Enables the effect on given cameras
  63944. * @param cameras The camera to enable.
  63945. * @hidden
  63946. */
  63947. _enable(cameras: Camera): void;
  63948. /**
  63949. * Enables the effect on given cameras
  63950. * @param cameras The camera to enable.
  63951. * @hidden
  63952. */
  63953. _enable(cameras: Nullable<Camera[]>): void;
  63954. /**
  63955. * Disables the effect on the given cameras
  63956. * @param cameras The camera to disable.
  63957. * @hidden
  63958. */
  63959. _disable(cameras: Camera): void;
  63960. /**
  63961. * Disables the effect on the given cameras
  63962. * @param cameras The camera to disable.
  63963. * @hidden
  63964. */
  63965. _disable(cameras: Nullable<Camera[]>): void;
  63966. /**
  63967. * Gets a list of the post processes contained in the effect.
  63968. * @param camera The camera to get the post processes on.
  63969. * @returns The list of the post processes in the effect.
  63970. */
  63971. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63972. }
  63973. }
  63974. declare module BABYLON {
  63975. /** @hidden */
  63976. export var extractHighlightsPixelShader: {
  63977. name: string;
  63978. shader: string;
  63979. };
  63980. }
  63981. declare module BABYLON {
  63982. /**
  63983. * 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.
  63984. */
  63985. export class ExtractHighlightsPostProcess extends PostProcess {
  63986. /**
  63987. * The luminance threshold, pixels below this value will be set to black.
  63988. */
  63989. threshold: number;
  63990. /** @hidden */
  63991. _exposure: number;
  63992. /**
  63993. * Post process which has the input texture to be used when performing highlight extraction
  63994. * @hidden
  63995. */
  63996. _inputPostProcess: Nullable<PostProcess>;
  63997. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63998. }
  63999. }
  64000. declare module BABYLON {
  64001. /** @hidden */
  64002. export var bloomMergePixelShader: {
  64003. name: string;
  64004. shader: string;
  64005. };
  64006. }
  64007. declare module BABYLON {
  64008. /**
  64009. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64010. */
  64011. export class BloomMergePostProcess extends PostProcess {
  64012. /** Weight of the bloom to be added to the original input. */
  64013. weight: number;
  64014. /**
  64015. * Creates a new instance of @see BloomMergePostProcess
  64016. * @param name The name of the effect.
  64017. * @param originalFromInput Post process which's input will be used for the merge.
  64018. * @param blurred Blurred highlights post process which's output will be used.
  64019. * @param weight Weight of the bloom to be added to the original input.
  64020. * @param options The required width/height ratio to downsize to before computing the render pass.
  64021. * @param camera The camera to apply the render pass to.
  64022. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64023. * @param engine The engine which the post process will be applied. (default: current engine)
  64024. * @param reusable If the post process can be reused on the same frame. (default: false)
  64025. * @param textureType Type of textures used when performing the post process. (default: 0)
  64026. * @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)
  64027. */
  64028. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64029. /** Weight of the bloom to be added to the original input. */
  64030. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64031. }
  64032. }
  64033. declare module BABYLON {
  64034. /**
  64035. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64036. */
  64037. export class BloomEffect extends PostProcessRenderEffect {
  64038. private bloomScale;
  64039. /**
  64040. * @hidden Internal
  64041. */
  64042. _effects: Array<PostProcess>;
  64043. /**
  64044. * @hidden Internal
  64045. */
  64046. _downscale: ExtractHighlightsPostProcess;
  64047. private _blurX;
  64048. private _blurY;
  64049. private _merge;
  64050. /**
  64051. * The luminance threshold to find bright areas of the image to bloom.
  64052. */
  64053. get threshold(): number;
  64054. set threshold(value: number);
  64055. /**
  64056. * The strength of the bloom.
  64057. */
  64058. get weight(): number;
  64059. set weight(value: number);
  64060. /**
  64061. * Specifies the size of the bloom blur kernel, relative to the final output size
  64062. */
  64063. get kernel(): number;
  64064. set kernel(value: number);
  64065. /**
  64066. * Creates a new instance of @see BloomEffect
  64067. * @param scene The scene the effect belongs to.
  64068. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64069. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64070. * @param bloomWeight The the strength of bloom.
  64071. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64072. * @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)
  64073. */
  64074. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64075. /**
  64076. * Disposes each of the internal effects for a given camera.
  64077. * @param camera The camera to dispose the effect on.
  64078. */
  64079. disposeEffects(camera: Camera): void;
  64080. /**
  64081. * @hidden Internal
  64082. */
  64083. _updateEffects(): void;
  64084. /**
  64085. * Internal
  64086. * @returns if all the contained post processes are ready.
  64087. * @hidden
  64088. */
  64089. _isReady(): boolean;
  64090. }
  64091. }
  64092. declare module BABYLON {
  64093. /** @hidden */
  64094. export var chromaticAberrationPixelShader: {
  64095. name: string;
  64096. shader: string;
  64097. };
  64098. }
  64099. declare module BABYLON {
  64100. /**
  64101. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64102. */
  64103. export class ChromaticAberrationPostProcess extends PostProcess {
  64104. /**
  64105. * The amount of seperation of rgb channels (default: 30)
  64106. */
  64107. aberrationAmount: number;
  64108. /**
  64109. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64110. */
  64111. radialIntensity: number;
  64112. /**
  64113. * 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))
  64114. */
  64115. direction: Vector2;
  64116. /**
  64117. * 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))
  64118. */
  64119. centerPosition: Vector2;
  64120. /**
  64121. * Creates a new instance ChromaticAberrationPostProcess
  64122. * @param name The name of the effect.
  64123. * @param screenWidth The width of the screen to apply the effect on.
  64124. * @param screenHeight The height of the screen to apply the effect on.
  64125. * @param options The required width/height ratio to downsize to before computing the render pass.
  64126. * @param camera The camera to apply the render pass to.
  64127. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64128. * @param engine The engine which the post process will be applied. (default: current engine)
  64129. * @param reusable If the post process can be reused on the same frame. (default: false)
  64130. * @param textureType Type of textures used when performing the post process. (default: 0)
  64131. * @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)
  64132. */
  64133. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64134. }
  64135. }
  64136. declare module BABYLON {
  64137. /** @hidden */
  64138. export var circleOfConfusionPixelShader: {
  64139. name: string;
  64140. shader: string;
  64141. };
  64142. }
  64143. declare module BABYLON {
  64144. /**
  64145. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64146. */
  64147. export class CircleOfConfusionPostProcess extends PostProcess {
  64148. /**
  64149. * 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.
  64150. */
  64151. lensSize: number;
  64152. /**
  64153. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64154. */
  64155. fStop: number;
  64156. /**
  64157. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64158. */
  64159. focusDistance: number;
  64160. /**
  64161. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64162. */
  64163. focalLength: number;
  64164. private _depthTexture;
  64165. /**
  64166. * Creates a new instance CircleOfConfusionPostProcess
  64167. * @param name The name of the effect.
  64168. * @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.
  64169. * @param options The required width/height ratio to downsize to before computing the render pass.
  64170. * @param camera The camera to apply the render pass to.
  64171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64172. * @param engine The engine which the post process will be applied. (default: current engine)
  64173. * @param reusable If the post process can be reused on the same frame. (default: false)
  64174. * @param textureType Type of textures used when performing the post process. (default: 0)
  64175. * @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)
  64176. */
  64177. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64178. /**
  64179. * 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.
  64180. */
  64181. set depthTexture(value: RenderTargetTexture);
  64182. }
  64183. }
  64184. declare module BABYLON {
  64185. /** @hidden */
  64186. export var colorCorrectionPixelShader: {
  64187. name: string;
  64188. shader: string;
  64189. };
  64190. }
  64191. declare module BABYLON {
  64192. /**
  64193. *
  64194. * This post-process allows the modification of rendered colors by using
  64195. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64196. *
  64197. * The object needs to be provided an url to a texture containing the color
  64198. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64199. * Use an image editing software to tweak the LUT to match your needs.
  64200. *
  64201. * For an example of a color LUT, see here:
  64202. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64203. * For explanations on color grading, see here:
  64204. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64205. *
  64206. */
  64207. export class ColorCorrectionPostProcess extends PostProcess {
  64208. private _colorTableTexture;
  64209. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64210. }
  64211. }
  64212. declare module BABYLON {
  64213. /** @hidden */
  64214. export var convolutionPixelShader: {
  64215. name: string;
  64216. shader: string;
  64217. };
  64218. }
  64219. declare module BABYLON {
  64220. /**
  64221. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64222. * input texture to perform effects such as edge detection or sharpening
  64223. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64224. */
  64225. export class ConvolutionPostProcess extends PostProcess {
  64226. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64227. kernel: number[];
  64228. /**
  64229. * Creates a new instance ConvolutionPostProcess
  64230. * @param name The name of the effect.
  64231. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64232. * @param options The required width/height ratio to downsize to before computing the render pass.
  64233. * @param camera The camera to apply the render pass to.
  64234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64235. * @param engine The engine which the post process will be applied. (default: current engine)
  64236. * @param reusable If the post process can be reused on the same frame. (default: false)
  64237. * @param textureType Type of textures used when performing the post process. (default: 0)
  64238. */
  64239. constructor(name: string,
  64240. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64241. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64242. /**
  64243. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64244. */
  64245. static EdgeDetect0Kernel: number[];
  64246. /**
  64247. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64248. */
  64249. static EdgeDetect1Kernel: number[];
  64250. /**
  64251. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64252. */
  64253. static EdgeDetect2Kernel: number[];
  64254. /**
  64255. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64256. */
  64257. static SharpenKernel: number[];
  64258. /**
  64259. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64260. */
  64261. static EmbossKernel: number[];
  64262. /**
  64263. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64264. */
  64265. static GaussianKernel: number[];
  64266. }
  64267. }
  64268. declare module BABYLON {
  64269. /**
  64270. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64271. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64272. * based on samples that have a large difference in distance than the center pixel.
  64273. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64274. */
  64275. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64276. direction: Vector2;
  64277. /**
  64278. * Creates a new instance CircleOfConfusionPostProcess
  64279. * @param name The name of the effect.
  64280. * @param scene The scene the effect belongs to.
  64281. * @param direction The direction the blur should be applied.
  64282. * @param kernel The size of the kernel used to blur.
  64283. * @param options The required width/height ratio to downsize to before computing the render pass.
  64284. * @param camera The camera to apply the render pass to.
  64285. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64286. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64288. * @param engine The engine which the post process will be applied. (default: current engine)
  64289. * @param reusable If the post process can be reused on the same frame. (default: false)
  64290. * @param textureType Type of textures used when performing the post process. (default: 0)
  64291. * @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)
  64292. */
  64293. 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);
  64294. }
  64295. }
  64296. declare module BABYLON {
  64297. /** @hidden */
  64298. export var depthOfFieldMergePixelShader: {
  64299. name: string;
  64300. shader: string;
  64301. };
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * Options to be set when merging outputs from the default pipeline.
  64306. */
  64307. export class DepthOfFieldMergePostProcessOptions {
  64308. /**
  64309. * The original image to merge on top of
  64310. */
  64311. originalFromInput: PostProcess;
  64312. /**
  64313. * Parameters to perform the merge of the depth of field effect
  64314. */
  64315. depthOfField?: {
  64316. circleOfConfusion: PostProcess;
  64317. blurSteps: Array<PostProcess>;
  64318. };
  64319. /**
  64320. * Parameters to perform the merge of bloom effect
  64321. */
  64322. bloom?: {
  64323. blurred: PostProcess;
  64324. weight: number;
  64325. };
  64326. }
  64327. /**
  64328. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64329. */
  64330. export class DepthOfFieldMergePostProcess extends PostProcess {
  64331. private blurSteps;
  64332. /**
  64333. * Creates a new instance of DepthOfFieldMergePostProcess
  64334. * @param name The name of the effect.
  64335. * @param originalFromInput Post process which's input will be used for the merge.
  64336. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64337. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64338. * @param options The required width/height ratio to downsize to before computing the render pass.
  64339. * @param camera The camera to apply the render pass to.
  64340. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64341. * @param engine The engine which the post process will be applied. (default: current engine)
  64342. * @param reusable If the post process can be reused on the same frame. (default: false)
  64343. * @param textureType Type of textures used when performing the post process. (default: 0)
  64344. * @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)
  64345. */
  64346. 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);
  64347. /**
  64348. * Updates the effect with the current post process compile time values and recompiles the shader.
  64349. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64350. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64351. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64352. * @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
  64353. * @param onCompiled Called when the shader has been compiled.
  64354. * @param onError Called if there is an error when compiling a shader.
  64355. */
  64356. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64357. }
  64358. }
  64359. declare module BABYLON {
  64360. /**
  64361. * Specifies the level of max blur that should be applied when using the depth of field effect
  64362. */
  64363. export enum DepthOfFieldEffectBlurLevel {
  64364. /**
  64365. * Subtle blur
  64366. */
  64367. Low = 0,
  64368. /**
  64369. * Medium blur
  64370. */
  64371. Medium = 1,
  64372. /**
  64373. * Large blur
  64374. */
  64375. High = 2
  64376. }
  64377. /**
  64378. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64379. */
  64380. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64381. private _circleOfConfusion;
  64382. /**
  64383. * @hidden Internal, blurs from high to low
  64384. */
  64385. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64386. private _depthOfFieldBlurY;
  64387. private _dofMerge;
  64388. /**
  64389. * @hidden Internal post processes in depth of field effect
  64390. */
  64391. _effects: Array<PostProcess>;
  64392. /**
  64393. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64394. */
  64395. set focalLength(value: number);
  64396. get focalLength(): number;
  64397. /**
  64398. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64399. */
  64400. set fStop(value: number);
  64401. get fStop(): number;
  64402. /**
  64403. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64404. */
  64405. set focusDistance(value: number);
  64406. get focusDistance(): number;
  64407. /**
  64408. * 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.
  64409. */
  64410. set lensSize(value: number);
  64411. get lensSize(): number;
  64412. /**
  64413. * Creates a new instance DepthOfFieldEffect
  64414. * @param scene The scene the effect belongs to.
  64415. * @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.
  64416. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64417. * @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)
  64418. */
  64419. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64420. /**
  64421. * Get the current class name of the current effet
  64422. * @returns "DepthOfFieldEffect"
  64423. */
  64424. getClassName(): string;
  64425. /**
  64426. * 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.
  64427. */
  64428. set depthTexture(value: RenderTargetTexture);
  64429. /**
  64430. * Disposes each of the internal effects for a given camera.
  64431. * @param camera The camera to dispose the effect on.
  64432. */
  64433. disposeEffects(camera: Camera): void;
  64434. /**
  64435. * @hidden Internal
  64436. */
  64437. _updateEffects(): void;
  64438. /**
  64439. * Internal
  64440. * @returns if all the contained post processes are ready.
  64441. * @hidden
  64442. */
  64443. _isReady(): boolean;
  64444. }
  64445. }
  64446. declare module BABYLON {
  64447. /** @hidden */
  64448. export var displayPassPixelShader: {
  64449. name: string;
  64450. shader: string;
  64451. };
  64452. }
  64453. declare module BABYLON {
  64454. /**
  64455. * DisplayPassPostProcess which produces an output the same as it's input
  64456. */
  64457. export class DisplayPassPostProcess extends PostProcess {
  64458. /**
  64459. * Creates the DisplayPassPostProcess
  64460. * @param name The name of the effect.
  64461. * @param options The required width/height ratio to downsize to before computing the render pass.
  64462. * @param camera The camera to apply the render pass to.
  64463. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64464. * @param engine The engine which the post process will be applied. (default: current engine)
  64465. * @param reusable If the post process can be reused on the same frame. (default: false)
  64466. */
  64467. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64468. }
  64469. }
  64470. declare module BABYLON {
  64471. /** @hidden */
  64472. export var filterPixelShader: {
  64473. name: string;
  64474. shader: string;
  64475. };
  64476. }
  64477. declare module BABYLON {
  64478. /**
  64479. * Applies a kernel filter to the image
  64480. */
  64481. export class FilterPostProcess extends PostProcess {
  64482. /** The matrix to be applied to the image */
  64483. kernelMatrix: Matrix;
  64484. /**
  64485. *
  64486. * @param name The name of the effect.
  64487. * @param kernelMatrix The matrix to be applied to the image
  64488. * @param options The required width/height ratio to downsize to before computing the render pass.
  64489. * @param camera The camera to apply the render pass to.
  64490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64491. * @param engine The engine which the post process will be applied. (default: current engine)
  64492. * @param reusable If the post process can be reused on the same frame. (default: false)
  64493. */
  64494. constructor(name: string,
  64495. /** The matrix to be applied to the image */
  64496. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64497. }
  64498. }
  64499. declare module BABYLON {
  64500. /** @hidden */
  64501. export var fxaaPixelShader: {
  64502. name: string;
  64503. shader: string;
  64504. };
  64505. }
  64506. declare module BABYLON {
  64507. /** @hidden */
  64508. export var fxaaVertexShader: {
  64509. name: string;
  64510. shader: string;
  64511. };
  64512. }
  64513. declare module BABYLON {
  64514. /**
  64515. * Fxaa post process
  64516. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64517. */
  64518. export class FxaaPostProcess extends PostProcess {
  64519. /** @hidden */
  64520. texelWidth: number;
  64521. /** @hidden */
  64522. texelHeight: number;
  64523. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64524. private _getDefines;
  64525. }
  64526. }
  64527. declare module BABYLON {
  64528. /** @hidden */
  64529. export var grainPixelShader: {
  64530. name: string;
  64531. shader: string;
  64532. };
  64533. }
  64534. declare module BABYLON {
  64535. /**
  64536. * The GrainPostProcess adds noise to the image at mid luminance levels
  64537. */
  64538. export class GrainPostProcess extends PostProcess {
  64539. /**
  64540. * The intensity of the grain added (default: 30)
  64541. */
  64542. intensity: number;
  64543. /**
  64544. * If the grain should be randomized on every frame
  64545. */
  64546. animated: boolean;
  64547. /**
  64548. * Creates a new instance of @see GrainPostProcess
  64549. * @param name The name of the effect.
  64550. * @param options The required width/height ratio to downsize to before computing the render pass.
  64551. * @param camera The camera to apply the render pass to.
  64552. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64553. * @param engine The engine which the post process will be applied. (default: current engine)
  64554. * @param reusable If the post process can be reused on the same frame. (default: false)
  64555. * @param textureType Type of textures used when performing the post process. (default: 0)
  64556. * @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)
  64557. */
  64558. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64559. }
  64560. }
  64561. declare module BABYLON {
  64562. /** @hidden */
  64563. export var highlightsPixelShader: {
  64564. name: string;
  64565. shader: string;
  64566. };
  64567. }
  64568. declare module BABYLON {
  64569. /**
  64570. * Extracts highlights from the image
  64571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64572. */
  64573. export class HighlightsPostProcess extends PostProcess {
  64574. /**
  64575. * Extracts highlights from the image
  64576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64577. * @param name The name of the effect.
  64578. * @param options The required width/height ratio to downsize to before computing the render pass.
  64579. * @param camera The camera to apply the render pass to.
  64580. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64581. * @param engine The engine which the post process will be applied. (default: current engine)
  64582. * @param reusable If the post process can be reused on the same frame. (default: false)
  64583. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64584. */
  64585. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64586. }
  64587. }
  64588. declare module BABYLON {
  64589. /** @hidden */
  64590. export var mrtFragmentDeclaration: {
  64591. name: string;
  64592. shader: string;
  64593. };
  64594. }
  64595. declare module BABYLON {
  64596. /** @hidden */
  64597. export var geometryPixelShader: {
  64598. name: string;
  64599. shader: string;
  64600. };
  64601. }
  64602. declare module BABYLON {
  64603. /** @hidden */
  64604. export var geometryVertexShader: {
  64605. name: string;
  64606. shader: string;
  64607. };
  64608. }
  64609. declare module BABYLON {
  64610. /** @hidden */
  64611. interface ISavedTransformationMatrix {
  64612. world: Matrix;
  64613. viewProjection: Matrix;
  64614. }
  64615. /**
  64616. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64617. */
  64618. export class GeometryBufferRenderer {
  64619. /**
  64620. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64621. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64622. */
  64623. static readonly POSITION_TEXTURE_TYPE: number;
  64624. /**
  64625. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64626. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64627. */
  64628. static readonly VELOCITY_TEXTURE_TYPE: number;
  64629. /**
  64630. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64631. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64632. */
  64633. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64634. /**
  64635. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64636. * in order to compute objects velocities when enableVelocity is set to "true"
  64637. * @hidden
  64638. */
  64639. _previousTransformationMatrices: {
  64640. [index: number]: ISavedTransformationMatrix;
  64641. };
  64642. /**
  64643. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64644. * in order to compute objects velocities when enableVelocity is set to "true"
  64645. * @hidden
  64646. */
  64647. _previousBonesTransformationMatrices: {
  64648. [index: number]: Float32Array;
  64649. };
  64650. /**
  64651. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64652. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64653. */
  64654. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64655. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64656. renderTransparentMeshes: boolean;
  64657. private _scene;
  64658. private _multiRenderTarget;
  64659. private _ratio;
  64660. private _enablePosition;
  64661. private _enableVelocity;
  64662. private _enableReflectivity;
  64663. private _positionIndex;
  64664. private _velocityIndex;
  64665. private _reflectivityIndex;
  64666. protected _effect: Effect;
  64667. protected _cachedDefines: string;
  64668. /**
  64669. * Set the render list (meshes to be rendered) used in the G buffer.
  64670. */
  64671. set renderList(meshes: Mesh[]);
  64672. /**
  64673. * Gets wether or not G buffer are supported by the running hardware.
  64674. * This requires draw buffer supports
  64675. */
  64676. get isSupported(): boolean;
  64677. /**
  64678. * Returns the index of the given texture type in the G-Buffer textures array
  64679. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64680. * @returns the index of the given texture type in the G-Buffer textures array
  64681. */
  64682. getTextureIndex(textureType: number): number;
  64683. /**
  64684. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64685. */
  64686. get enablePosition(): boolean;
  64687. /**
  64688. * Sets whether or not objects positions are enabled for the G buffer.
  64689. */
  64690. set enablePosition(enable: boolean);
  64691. /**
  64692. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64693. */
  64694. get enableVelocity(): boolean;
  64695. /**
  64696. * Sets wether or not objects velocities are enabled for the G buffer.
  64697. */
  64698. set enableVelocity(enable: boolean);
  64699. /**
  64700. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64701. */
  64702. get enableReflectivity(): boolean;
  64703. /**
  64704. * Sets wether or not objects roughness are enabled for the G buffer.
  64705. */
  64706. set enableReflectivity(enable: boolean);
  64707. /**
  64708. * Gets the scene associated with the buffer.
  64709. */
  64710. get scene(): Scene;
  64711. /**
  64712. * Gets the ratio used by the buffer during its creation.
  64713. * How big is the buffer related to the main canvas.
  64714. */
  64715. get ratio(): number;
  64716. /** @hidden */
  64717. static _SceneComponentInitialization: (scene: Scene) => void;
  64718. /**
  64719. * Creates a new G Buffer for the scene
  64720. * @param scene The scene the buffer belongs to
  64721. * @param ratio How big is the buffer related to the main canvas.
  64722. */
  64723. constructor(scene: Scene, ratio?: number);
  64724. /**
  64725. * Checks wether everything is ready to render a submesh to the G buffer.
  64726. * @param subMesh the submesh to check readiness for
  64727. * @param useInstances is the mesh drawn using instance or not
  64728. * @returns true if ready otherwise false
  64729. */
  64730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64731. /**
  64732. * Gets the current underlying G Buffer.
  64733. * @returns the buffer
  64734. */
  64735. getGBuffer(): MultiRenderTarget;
  64736. /**
  64737. * Gets the number of samples used to render the buffer (anti aliasing).
  64738. */
  64739. get samples(): number;
  64740. /**
  64741. * Sets the number of samples used to render the buffer (anti aliasing).
  64742. */
  64743. set samples(value: number);
  64744. /**
  64745. * Disposes the renderer and frees up associated resources.
  64746. */
  64747. dispose(): void;
  64748. protected _createRenderTargets(): void;
  64749. private _copyBonesTransformationMatrices;
  64750. }
  64751. }
  64752. declare module BABYLON {
  64753. interface Scene {
  64754. /** @hidden (Backing field) */
  64755. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64756. /**
  64757. * Gets or Sets the current geometry buffer associated to the scene.
  64758. */
  64759. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64760. /**
  64761. * Enables a GeometryBufferRender and associates it with the scene
  64762. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64763. * @returns the GeometryBufferRenderer
  64764. */
  64765. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64766. /**
  64767. * Disables the GeometryBufferRender associated with the scene
  64768. */
  64769. disableGeometryBufferRenderer(): void;
  64770. }
  64771. /**
  64772. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64773. * in several rendering techniques.
  64774. */
  64775. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64776. /**
  64777. * The component name helpful to identify the component in the list of scene components.
  64778. */
  64779. readonly name: string;
  64780. /**
  64781. * The scene the component belongs to.
  64782. */
  64783. scene: Scene;
  64784. /**
  64785. * Creates a new instance of the component for the given scene
  64786. * @param scene Defines the scene to register the component in
  64787. */
  64788. constructor(scene: Scene);
  64789. /**
  64790. * Registers the component in a given scene
  64791. */
  64792. register(): void;
  64793. /**
  64794. * Rebuilds the elements related to this component in case of
  64795. * context lost for instance.
  64796. */
  64797. rebuild(): void;
  64798. /**
  64799. * Disposes the component and the associated ressources
  64800. */
  64801. dispose(): void;
  64802. private _gatherRenderTargets;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /** @hidden */
  64807. export var motionBlurPixelShader: {
  64808. name: string;
  64809. shader: string;
  64810. };
  64811. }
  64812. declare module BABYLON {
  64813. /**
  64814. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64815. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64816. * As an example, all you have to do is to create the post-process:
  64817. * var mb = new BABYLON.MotionBlurPostProcess(
  64818. * 'mb', // The name of the effect.
  64819. * scene, // The scene containing the objects to blur according to their velocity.
  64820. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64821. * camera // The camera to apply the render pass to.
  64822. * );
  64823. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64824. */
  64825. export class MotionBlurPostProcess extends PostProcess {
  64826. /**
  64827. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64828. */
  64829. motionStrength: number;
  64830. /**
  64831. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64832. */
  64833. get motionBlurSamples(): number;
  64834. /**
  64835. * Sets the number of iterations to be used for motion blur quality
  64836. */
  64837. set motionBlurSamples(samples: number);
  64838. private _motionBlurSamples;
  64839. private _geometryBufferRenderer;
  64840. /**
  64841. * Creates a new instance MotionBlurPostProcess
  64842. * @param name The name of the effect.
  64843. * @param scene The scene containing the objects to blur according to their velocity.
  64844. * @param options The required width/height ratio to downsize to before computing the render pass.
  64845. * @param camera The camera to apply the render pass to.
  64846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64847. * @param engine The engine which the post process will be applied. (default: current engine)
  64848. * @param reusable If the post process can be reused on the same frame. (default: false)
  64849. * @param textureType Type of textures used when performing the post process. (default: 0)
  64850. * @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)
  64851. */
  64852. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64853. /**
  64854. * Excludes the given skinned mesh from computing bones velocities.
  64855. * 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.
  64856. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64857. */
  64858. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64859. /**
  64860. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64861. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64862. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64863. */
  64864. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64865. /**
  64866. * Disposes the post process.
  64867. * @param camera The camera to dispose the post process on.
  64868. */
  64869. dispose(camera?: Camera): void;
  64870. }
  64871. }
  64872. declare module BABYLON {
  64873. /** @hidden */
  64874. export var refractionPixelShader: {
  64875. name: string;
  64876. shader: string;
  64877. };
  64878. }
  64879. declare module BABYLON {
  64880. /**
  64881. * Post process which applies a refractin texture
  64882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64883. */
  64884. export class RefractionPostProcess extends PostProcess {
  64885. /** the base color of the refraction (used to taint the rendering) */
  64886. color: Color3;
  64887. /** simulated refraction depth */
  64888. depth: number;
  64889. /** the coefficient of the base color (0 to remove base color tainting) */
  64890. colorLevel: number;
  64891. private _refTexture;
  64892. private _ownRefractionTexture;
  64893. /**
  64894. * Gets or sets the refraction texture
  64895. * Please note that you are responsible for disposing the texture if you set it manually
  64896. */
  64897. get refractionTexture(): Texture;
  64898. set refractionTexture(value: Texture);
  64899. /**
  64900. * Initializes the RefractionPostProcess
  64901. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64902. * @param name The name of the effect.
  64903. * @param refractionTextureUrl Url of the refraction texture to use
  64904. * @param color the base color of the refraction (used to taint the rendering)
  64905. * @param depth simulated refraction depth
  64906. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64907. * @param camera The camera to apply the render pass to.
  64908. * @param options The required width/height ratio to downsize to before computing the render pass.
  64909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64910. * @param engine The engine which the post process will be applied. (default: current engine)
  64911. * @param reusable If the post process can be reused on the same frame. (default: false)
  64912. */
  64913. constructor(name: string, refractionTextureUrl: string,
  64914. /** the base color of the refraction (used to taint the rendering) */
  64915. color: Color3,
  64916. /** simulated refraction depth */
  64917. depth: number,
  64918. /** the coefficient of the base color (0 to remove base color tainting) */
  64919. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64920. /**
  64921. * Disposes of the post process
  64922. * @param camera Camera to dispose post process on
  64923. */
  64924. dispose(camera: Camera): void;
  64925. }
  64926. }
  64927. declare module BABYLON {
  64928. /** @hidden */
  64929. export var sharpenPixelShader: {
  64930. name: string;
  64931. shader: string;
  64932. };
  64933. }
  64934. declare module BABYLON {
  64935. /**
  64936. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64937. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64938. */
  64939. export class SharpenPostProcess extends PostProcess {
  64940. /**
  64941. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64942. */
  64943. colorAmount: number;
  64944. /**
  64945. * How much sharpness should be applied (default: 0.3)
  64946. */
  64947. edgeAmount: number;
  64948. /**
  64949. * Creates a new instance ConvolutionPostProcess
  64950. * @param name The name of the effect.
  64951. * @param options The required width/height ratio to downsize to before computing the render pass.
  64952. * @param camera The camera to apply the render pass to.
  64953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64954. * @param engine The engine which the post process will be applied. (default: current engine)
  64955. * @param reusable If the post process can be reused on the same frame. (default: false)
  64956. * @param textureType Type of textures used when performing the post process. (default: 0)
  64957. * @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)
  64958. */
  64959. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64960. }
  64961. }
  64962. declare module BABYLON {
  64963. /**
  64964. * PostProcessRenderPipeline
  64965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64966. */
  64967. export class PostProcessRenderPipeline {
  64968. private engine;
  64969. private _renderEffects;
  64970. private _renderEffectsForIsolatedPass;
  64971. /**
  64972. * List of inspectable custom properties (used by the Inspector)
  64973. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64974. */
  64975. inspectableCustomProperties: IInspectable[];
  64976. /**
  64977. * @hidden
  64978. */
  64979. protected _cameras: Camera[];
  64980. /** @hidden */
  64981. _name: string;
  64982. /**
  64983. * Gets pipeline name
  64984. */
  64985. get name(): string;
  64986. /** Gets the list of attached cameras */
  64987. get cameras(): Camera[];
  64988. /**
  64989. * Initializes a PostProcessRenderPipeline
  64990. * @param engine engine to add the pipeline to
  64991. * @param name name of the pipeline
  64992. */
  64993. constructor(engine: Engine, name: string);
  64994. /**
  64995. * Gets the class name
  64996. * @returns "PostProcessRenderPipeline"
  64997. */
  64998. getClassName(): string;
  64999. /**
  65000. * If all the render effects in the pipeline are supported
  65001. */
  65002. get isSupported(): boolean;
  65003. /**
  65004. * Adds an effect to the pipeline
  65005. * @param renderEffect the effect to add
  65006. */
  65007. addEffect(renderEffect: PostProcessRenderEffect): void;
  65008. /** @hidden */
  65009. _rebuild(): void;
  65010. /** @hidden */
  65011. _enableEffect(renderEffectName: string, cameras: Camera): void;
  65012. /** @hidden */
  65013. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  65014. /** @hidden */
  65015. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65016. /** @hidden */
  65017. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65018. /** @hidden */
  65019. _attachCameras(cameras: Camera, unique: boolean): void;
  65020. /** @hidden */
  65021. _attachCameras(cameras: Camera[], unique: boolean): void;
  65022. /** @hidden */
  65023. _detachCameras(cameras: Camera): void;
  65024. /** @hidden */
  65025. _detachCameras(cameras: Nullable<Camera[]>): void;
  65026. /** @hidden */
  65027. _update(): void;
  65028. /** @hidden */
  65029. _reset(): void;
  65030. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65031. /**
  65032. * Disposes of the pipeline
  65033. */
  65034. dispose(): void;
  65035. }
  65036. }
  65037. declare module BABYLON {
  65038. /**
  65039. * PostProcessRenderPipelineManager class
  65040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65041. */
  65042. export class PostProcessRenderPipelineManager {
  65043. private _renderPipelines;
  65044. /**
  65045. * Initializes a PostProcessRenderPipelineManager
  65046. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65047. */
  65048. constructor();
  65049. /**
  65050. * Gets the list of supported render pipelines
  65051. */
  65052. get supportedPipelines(): PostProcessRenderPipeline[];
  65053. /**
  65054. * Adds a pipeline to the manager
  65055. * @param renderPipeline The pipeline to add
  65056. */
  65057. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65058. /**
  65059. * Attaches a camera to the pipeline
  65060. * @param renderPipelineName The name of the pipeline to attach to
  65061. * @param cameras the camera to attach
  65062. * @param unique if the camera can be attached multiple times to the pipeline
  65063. */
  65064. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65065. /**
  65066. * Detaches a camera from the pipeline
  65067. * @param renderPipelineName The name of the pipeline to detach from
  65068. * @param cameras the camera to detach
  65069. */
  65070. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65071. /**
  65072. * Enables an effect by name on a pipeline
  65073. * @param renderPipelineName the name of the pipeline to enable the effect in
  65074. * @param renderEffectName the name of the effect to enable
  65075. * @param cameras the cameras that the effect should be enabled on
  65076. */
  65077. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65078. /**
  65079. * Disables an effect by name on a pipeline
  65080. * @param renderPipelineName the name of the pipeline to disable the effect in
  65081. * @param renderEffectName the name of the effect to disable
  65082. * @param cameras the cameras that the effect should be disabled on
  65083. */
  65084. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65085. /**
  65086. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65087. */
  65088. update(): void;
  65089. /** @hidden */
  65090. _rebuild(): void;
  65091. /**
  65092. * Disposes of the manager and pipelines
  65093. */
  65094. dispose(): void;
  65095. }
  65096. }
  65097. declare module BABYLON {
  65098. interface Scene {
  65099. /** @hidden (Backing field) */
  65100. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65101. /**
  65102. * Gets the postprocess render pipeline manager
  65103. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65104. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65105. */
  65106. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65107. }
  65108. /**
  65109. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65110. */
  65111. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65112. /**
  65113. * The component name helpfull to identify the component in the list of scene components.
  65114. */
  65115. readonly name: string;
  65116. /**
  65117. * The scene the component belongs to.
  65118. */
  65119. scene: Scene;
  65120. /**
  65121. * Creates a new instance of the component for the given scene
  65122. * @param scene Defines the scene to register the component in
  65123. */
  65124. constructor(scene: Scene);
  65125. /**
  65126. * Registers the component in a given scene
  65127. */
  65128. register(): void;
  65129. /**
  65130. * Rebuilds the elements related to this component in case of
  65131. * context lost for instance.
  65132. */
  65133. rebuild(): void;
  65134. /**
  65135. * Disposes the component and the associated ressources
  65136. */
  65137. dispose(): void;
  65138. private _gatherRenderTargets;
  65139. }
  65140. }
  65141. declare module BABYLON {
  65142. /**
  65143. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65144. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65145. */
  65146. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65147. private _scene;
  65148. private _camerasToBeAttached;
  65149. /**
  65150. * ID of the sharpen post process,
  65151. */
  65152. private readonly SharpenPostProcessId;
  65153. /**
  65154. * @ignore
  65155. * ID of the image processing post process;
  65156. */
  65157. readonly ImageProcessingPostProcessId: string;
  65158. /**
  65159. * @ignore
  65160. * ID of the Fast Approximate Anti-Aliasing post process;
  65161. */
  65162. readonly FxaaPostProcessId: string;
  65163. /**
  65164. * ID of the chromatic aberration post process,
  65165. */
  65166. private readonly ChromaticAberrationPostProcessId;
  65167. /**
  65168. * ID of the grain post process
  65169. */
  65170. private readonly GrainPostProcessId;
  65171. /**
  65172. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65173. */
  65174. sharpen: SharpenPostProcess;
  65175. private _sharpenEffect;
  65176. private bloom;
  65177. /**
  65178. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65179. */
  65180. depthOfField: DepthOfFieldEffect;
  65181. /**
  65182. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65183. */
  65184. fxaa: FxaaPostProcess;
  65185. /**
  65186. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65187. */
  65188. imageProcessing: ImageProcessingPostProcess;
  65189. /**
  65190. * Chromatic aberration post process which will shift rgb colors in the image
  65191. */
  65192. chromaticAberration: ChromaticAberrationPostProcess;
  65193. private _chromaticAberrationEffect;
  65194. /**
  65195. * Grain post process which add noise to the image
  65196. */
  65197. grain: GrainPostProcess;
  65198. private _grainEffect;
  65199. /**
  65200. * Glow post process which adds a glow to emissive areas of the image
  65201. */
  65202. private _glowLayer;
  65203. /**
  65204. * Animations which can be used to tweak settings over a period of time
  65205. */
  65206. animations: Animation[];
  65207. private _imageProcessingConfigurationObserver;
  65208. private _sharpenEnabled;
  65209. private _bloomEnabled;
  65210. private _depthOfFieldEnabled;
  65211. private _depthOfFieldBlurLevel;
  65212. private _fxaaEnabled;
  65213. private _imageProcessingEnabled;
  65214. private _defaultPipelineTextureType;
  65215. private _bloomScale;
  65216. private _chromaticAberrationEnabled;
  65217. private _grainEnabled;
  65218. private _buildAllowed;
  65219. /**
  65220. * Gets active scene
  65221. */
  65222. get scene(): Scene;
  65223. /**
  65224. * Enable or disable the sharpen process from the pipeline
  65225. */
  65226. set sharpenEnabled(enabled: boolean);
  65227. get sharpenEnabled(): boolean;
  65228. private _resizeObserver;
  65229. private _hardwareScaleLevel;
  65230. private _bloomKernel;
  65231. /**
  65232. * Specifies the size of the bloom blur kernel, relative to the final output size
  65233. */
  65234. get bloomKernel(): number;
  65235. set bloomKernel(value: number);
  65236. /**
  65237. * Specifies the weight of the bloom in the final rendering
  65238. */
  65239. private _bloomWeight;
  65240. /**
  65241. * Specifies the luma threshold for the area that will be blurred by the bloom
  65242. */
  65243. private _bloomThreshold;
  65244. private _hdr;
  65245. /**
  65246. * The strength of the bloom.
  65247. */
  65248. set bloomWeight(value: number);
  65249. get bloomWeight(): number;
  65250. /**
  65251. * The strength of the bloom.
  65252. */
  65253. set bloomThreshold(value: number);
  65254. get bloomThreshold(): number;
  65255. /**
  65256. * The scale of the bloom, lower value will provide better performance.
  65257. */
  65258. set bloomScale(value: number);
  65259. get bloomScale(): number;
  65260. /**
  65261. * Enable or disable the bloom from the pipeline
  65262. */
  65263. set bloomEnabled(enabled: boolean);
  65264. get bloomEnabled(): boolean;
  65265. private _rebuildBloom;
  65266. /**
  65267. * If the depth of field is enabled.
  65268. */
  65269. get depthOfFieldEnabled(): boolean;
  65270. set depthOfFieldEnabled(enabled: boolean);
  65271. /**
  65272. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65273. */
  65274. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65275. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65276. /**
  65277. * If the anti aliasing is enabled.
  65278. */
  65279. set fxaaEnabled(enabled: boolean);
  65280. get fxaaEnabled(): boolean;
  65281. private _samples;
  65282. /**
  65283. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65284. */
  65285. set samples(sampleCount: number);
  65286. get samples(): number;
  65287. /**
  65288. * If image processing is enabled.
  65289. */
  65290. set imageProcessingEnabled(enabled: boolean);
  65291. get imageProcessingEnabled(): boolean;
  65292. /**
  65293. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65294. */
  65295. set glowLayerEnabled(enabled: boolean);
  65296. get glowLayerEnabled(): boolean;
  65297. /**
  65298. * Gets the glow layer (or null if not defined)
  65299. */
  65300. get glowLayer(): Nullable<GlowLayer>;
  65301. /**
  65302. * Enable or disable the chromaticAberration process from the pipeline
  65303. */
  65304. set chromaticAberrationEnabled(enabled: boolean);
  65305. get chromaticAberrationEnabled(): boolean;
  65306. /**
  65307. * Enable or disable the grain process from the pipeline
  65308. */
  65309. set grainEnabled(enabled: boolean);
  65310. get grainEnabled(): boolean;
  65311. /**
  65312. * @constructor
  65313. * @param name - The rendering pipeline name (default: "")
  65314. * @param hdr - If high dynamic range textures should be used (default: true)
  65315. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65316. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65317. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65318. */
  65319. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65320. /**
  65321. * Get the class name
  65322. * @returns "DefaultRenderingPipeline"
  65323. */
  65324. getClassName(): string;
  65325. /**
  65326. * Force the compilation of the entire pipeline.
  65327. */
  65328. prepare(): void;
  65329. private _hasCleared;
  65330. private _prevPostProcess;
  65331. private _prevPrevPostProcess;
  65332. private _setAutoClearAndTextureSharing;
  65333. private _depthOfFieldSceneObserver;
  65334. private _buildPipeline;
  65335. private _disposePostProcesses;
  65336. /**
  65337. * Adds a camera to the pipeline
  65338. * @param camera the camera to be added
  65339. */
  65340. addCamera(camera: Camera): void;
  65341. /**
  65342. * Removes a camera from the pipeline
  65343. * @param camera the camera to remove
  65344. */
  65345. removeCamera(camera: Camera): void;
  65346. /**
  65347. * Dispose of the pipeline and stop all post processes
  65348. */
  65349. dispose(): void;
  65350. /**
  65351. * Serialize the rendering pipeline (Used when exporting)
  65352. * @returns the serialized object
  65353. */
  65354. serialize(): any;
  65355. /**
  65356. * Parse the serialized pipeline
  65357. * @param source Source pipeline.
  65358. * @param scene The scene to load the pipeline to.
  65359. * @param rootUrl The URL of the serialized pipeline.
  65360. * @returns An instantiated pipeline from the serialized object.
  65361. */
  65362. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65363. }
  65364. }
  65365. declare module BABYLON {
  65366. /** @hidden */
  65367. export var lensHighlightsPixelShader: {
  65368. name: string;
  65369. shader: string;
  65370. };
  65371. }
  65372. declare module BABYLON {
  65373. /** @hidden */
  65374. export var depthOfFieldPixelShader: {
  65375. name: string;
  65376. shader: string;
  65377. };
  65378. }
  65379. declare module BABYLON {
  65380. /**
  65381. * BABYLON.JS Chromatic Aberration GLSL Shader
  65382. * Author: Olivier Guyot
  65383. * Separates very slightly R, G and B colors on the edges of the screen
  65384. * Inspired by Francois Tarlier & Martins Upitis
  65385. */
  65386. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65387. /**
  65388. * @ignore
  65389. * The chromatic aberration PostProcess id in the pipeline
  65390. */
  65391. LensChromaticAberrationEffect: string;
  65392. /**
  65393. * @ignore
  65394. * The highlights enhancing PostProcess id in the pipeline
  65395. */
  65396. HighlightsEnhancingEffect: string;
  65397. /**
  65398. * @ignore
  65399. * The depth-of-field PostProcess id in the pipeline
  65400. */
  65401. LensDepthOfFieldEffect: string;
  65402. private _scene;
  65403. private _depthTexture;
  65404. private _grainTexture;
  65405. private _chromaticAberrationPostProcess;
  65406. private _highlightsPostProcess;
  65407. private _depthOfFieldPostProcess;
  65408. private _edgeBlur;
  65409. private _grainAmount;
  65410. private _chromaticAberration;
  65411. private _distortion;
  65412. private _highlightsGain;
  65413. private _highlightsThreshold;
  65414. private _dofDistance;
  65415. private _dofAperture;
  65416. private _dofDarken;
  65417. private _dofPentagon;
  65418. private _blurNoise;
  65419. /**
  65420. * @constructor
  65421. *
  65422. * Effect parameters are as follow:
  65423. * {
  65424. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65425. * edge_blur: number; // from 0 to x (1 for realism)
  65426. * distortion: number; // from 0 to x (1 for realism)
  65427. * grain_amount: number; // from 0 to 1
  65428. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65429. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65430. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65431. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65432. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65433. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65434. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65435. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65436. * }
  65437. * Note: if an effect parameter is unset, effect is disabled
  65438. *
  65439. * @param name The rendering pipeline name
  65440. * @param parameters - An object containing all parameters (see above)
  65441. * @param scene The scene linked to this pipeline
  65442. * @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)
  65443. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65444. */
  65445. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65446. /**
  65447. * Get the class name
  65448. * @returns "LensRenderingPipeline"
  65449. */
  65450. getClassName(): string;
  65451. /**
  65452. * Gets associated scene
  65453. */
  65454. get scene(): Scene;
  65455. /**
  65456. * Gets or sets the edge blur
  65457. */
  65458. get edgeBlur(): number;
  65459. set edgeBlur(value: number);
  65460. /**
  65461. * Gets or sets the grain amount
  65462. */
  65463. get grainAmount(): number;
  65464. set grainAmount(value: number);
  65465. /**
  65466. * Gets or sets the chromatic aberration amount
  65467. */
  65468. get chromaticAberration(): number;
  65469. set chromaticAberration(value: number);
  65470. /**
  65471. * Gets or sets the depth of field aperture
  65472. */
  65473. get dofAperture(): number;
  65474. set dofAperture(value: number);
  65475. /**
  65476. * Gets or sets the edge distortion
  65477. */
  65478. get edgeDistortion(): number;
  65479. set edgeDistortion(value: number);
  65480. /**
  65481. * Gets or sets the depth of field distortion
  65482. */
  65483. get dofDistortion(): number;
  65484. set dofDistortion(value: number);
  65485. /**
  65486. * Gets or sets the darken out of focus amount
  65487. */
  65488. get darkenOutOfFocus(): number;
  65489. set darkenOutOfFocus(value: number);
  65490. /**
  65491. * Gets or sets a boolean indicating if blur noise is enabled
  65492. */
  65493. get blurNoise(): boolean;
  65494. set blurNoise(value: boolean);
  65495. /**
  65496. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65497. */
  65498. get pentagonBokeh(): boolean;
  65499. set pentagonBokeh(value: boolean);
  65500. /**
  65501. * Gets or sets the highlight grain amount
  65502. */
  65503. get highlightsGain(): number;
  65504. set highlightsGain(value: number);
  65505. /**
  65506. * Gets or sets the highlight threshold
  65507. */
  65508. get highlightsThreshold(): number;
  65509. set highlightsThreshold(value: number);
  65510. /**
  65511. * Sets the amount of blur at the edges
  65512. * @param amount blur amount
  65513. */
  65514. setEdgeBlur(amount: number): void;
  65515. /**
  65516. * Sets edge blur to 0
  65517. */
  65518. disableEdgeBlur(): void;
  65519. /**
  65520. * Sets the amout of grain
  65521. * @param amount Amount of grain
  65522. */
  65523. setGrainAmount(amount: number): void;
  65524. /**
  65525. * Set grain amount to 0
  65526. */
  65527. disableGrain(): void;
  65528. /**
  65529. * Sets the chromatic aberration amount
  65530. * @param amount amount of chromatic aberration
  65531. */
  65532. setChromaticAberration(amount: number): void;
  65533. /**
  65534. * Sets chromatic aberration amount to 0
  65535. */
  65536. disableChromaticAberration(): void;
  65537. /**
  65538. * Sets the EdgeDistortion amount
  65539. * @param amount amount of EdgeDistortion
  65540. */
  65541. setEdgeDistortion(amount: number): void;
  65542. /**
  65543. * Sets edge distortion to 0
  65544. */
  65545. disableEdgeDistortion(): void;
  65546. /**
  65547. * Sets the FocusDistance amount
  65548. * @param amount amount of FocusDistance
  65549. */
  65550. setFocusDistance(amount: number): void;
  65551. /**
  65552. * Disables depth of field
  65553. */
  65554. disableDepthOfField(): void;
  65555. /**
  65556. * Sets the Aperture amount
  65557. * @param amount amount of Aperture
  65558. */
  65559. setAperture(amount: number): void;
  65560. /**
  65561. * Sets the DarkenOutOfFocus amount
  65562. * @param amount amount of DarkenOutOfFocus
  65563. */
  65564. setDarkenOutOfFocus(amount: number): void;
  65565. private _pentagonBokehIsEnabled;
  65566. /**
  65567. * Creates a pentagon bokeh effect
  65568. */
  65569. enablePentagonBokeh(): void;
  65570. /**
  65571. * Disables the pentagon bokeh effect
  65572. */
  65573. disablePentagonBokeh(): void;
  65574. /**
  65575. * Enables noise blur
  65576. */
  65577. enableNoiseBlur(): void;
  65578. /**
  65579. * Disables noise blur
  65580. */
  65581. disableNoiseBlur(): void;
  65582. /**
  65583. * Sets the HighlightsGain amount
  65584. * @param amount amount of HighlightsGain
  65585. */
  65586. setHighlightsGain(amount: number): void;
  65587. /**
  65588. * Sets the HighlightsThreshold amount
  65589. * @param amount amount of HighlightsThreshold
  65590. */
  65591. setHighlightsThreshold(amount: number): void;
  65592. /**
  65593. * Disables highlights
  65594. */
  65595. disableHighlights(): void;
  65596. /**
  65597. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65598. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65599. */
  65600. dispose(disableDepthRender?: boolean): void;
  65601. private _createChromaticAberrationPostProcess;
  65602. private _createHighlightsPostProcess;
  65603. private _createDepthOfFieldPostProcess;
  65604. private _createGrainTexture;
  65605. }
  65606. }
  65607. declare module BABYLON {
  65608. /** @hidden */
  65609. export var ssao2PixelShader: {
  65610. name: string;
  65611. shader: string;
  65612. };
  65613. }
  65614. declare module BABYLON {
  65615. /** @hidden */
  65616. export var ssaoCombinePixelShader: {
  65617. name: string;
  65618. shader: string;
  65619. };
  65620. }
  65621. declare module BABYLON {
  65622. /**
  65623. * Render pipeline to produce ssao effect
  65624. */
  65625. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65626. /**
  65627. * @ignore
  65628. * The PassPostProcess id in the pipeline that contains the original scene color
  65629. */
  65630. SSAOOriginalSceneColorEffect: string;
  65631. /**
  65632. * @ignore
  65633. * The SSAO PostProcess id in the pipeline
  65634. */
  65635. SSAORenderEffect: string;
  65636. /**
  65637. * @ignore
  65638. * The horizontal blur PostProcess id in the pipeline
  65639. */
  65640. SSAOBlurHRenderEffect: string;
  65641. /**
  65642. * @ignore
  65643. * The vertical blur PostProcess id in the pipeline
  65644. */
  65645. SSAOBlurVRenderEffect: string;
  65646. /**
  65647. * @ignore
  65648. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65649. */
  65650. SSAOCombineRenderEffect: string;
  65651. /**
  65652. * The output strength of the SSAO post-process. Default value is 1.0.
  65653. */
  65654. totalStrength: number;
  65655. /**
  65656. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65657. */
  65658. maxZ: number;
  65659. /**
  65660. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65661. */
  65662. minZAspect: number;
  65663. private _samples;
  65664. /**
  65665. * Number of samples used for the SSAO calculations. Default value is 8
  65666. */
  65667. set samples(n: number);
  65668. get samples(): number;
  65669. private _textureSamples;
  65670. /**
  65671. * Number of samples to use for antialiasing
  65672. */
  65673. set textureSamples(n: number);
  65674. get textureSamples(): number;
  65675. /**
  65676. * Ratio object used for SSAO ratio and blur ratio
  65677. */
  65678. private _ratio;
  65679. /**
  65680. * Dynamically generated sphere sampler.
  65681. */
  65682. private _sampleSphere;
  65683. /**
  65684. * Blur filter offsets
  65685. */
  65686. private _samplerOffsets;
  65687. private _expensiveBlur;
  65688. /**
  65689. * If bilateral blur should be used
  65690. */
  65691. set expensiveBlur(b: boolean);
  65692. get expensiveBlur(): boolean;
  65693. /**
  65694. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65695. */
  65696. radius: number;
  65697. /**
  65698. * The base color of the SSAO post-process
  65699. * The final result is "base + ssao" between [0, 1]
  65700. */
  65701. base: number;
  65702. /**
  65703. * Support test.
  65704. */
  65705. static get IsSupported(): boolean;
  65706. private _scene;
  65707. private _depthTexture;
  65708. private _normalTexture;
  65709. private _randomTexture;
  65710. private _originalColorPostProcess;
  65711. private _ssaoPostProcess;
  65712. private _blurHPostProcess;
  65713. private _blurVPostProcess;
  65714. private _ssaoCombinePostProcess;
  65715. /**
  65716. * Gets active scene
  65717. */
  65718. get scene(): Scene;
  65719. /**
  65720. * @constructor
  65721. * @param name The rendering pipeline name
  65722. * @param scene The scene linked to this pipeline
  65723. * @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 }
  65724. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65725. */
  65726. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65727. /**
  65728. * Get the class name
  65729. * @returns "SSAO2RenderingPipeline"
  65730. */
  65731. getClassName(): string;
  65732. /**
  65733. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65734. */
  65735. dispose(disableGeometryBufferRenderer?: boolean): void;
  65736. private _createBlurPostProcess;
  65737. /** @hidden */
  65738. _rebuild(): void;
  65739. private _bits;
  65740. private _radicalInverse_VdC;
  65741. private _hammersley;
  65742. private _hemisphereSample_uniform;
  65743. private _generateHemisphere;
  65744. private _createSSAOPostProcess;
  65745. private _createSSAOCombinePostProcess;
  65746. private _createRandomTexture;
  65747. /**
  65748. * Serialize the rendering pipeline (Used when exporting)
  65749. * @returns the serialized object
  65750. */
  65751. serialize(): any;
  65752. /**
  65753. * Parse the serialized pipeline
  65754. * @param source Source pipeline.
  65755. * @param scene The scene to load the pipeline to.
  65756. * @param rootUrl The URL of the serialized pipeline.
  65757. * @returns An instantiated pipeline from the serialized object.
  65758. */
  65759. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65760. }
  65761. }
  65762. declare module BABYLON {
  65763. /** @hidden */
  65764. export var ssaoPixelShader: {
  65765. name: string;
  65766. shader: string;
  65767. };
  65768. }
  65769. declare module BABYLON {
  65770. /**
  65771. * Render pipeline to produce ssao effect
  65772. */
  65773. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65774. /**
  65775. * @ignore
  65776. * The PassPostProcess id in the pipeline that contains the original scene color
  65777. */
  65778. SSAOOriginalSceneColorEffect: string;
  65779. /**
  65780. * @ignore
  65781. * The SSAO PostProcess id in the pipeline
  65782. */
  65783. SSAORenderEffect: string;
  65784. /**
  65785. * @ignore
  65786. * The horizontal blur PostProcess id in the pipeline
  65787. */
  65788. SSAOBlurHRenderEffect: string;
  65789. /**
  65790. * @ignore
  65791. * The vertical blur PostProcess id in the pipeline
  65792. */
  65793. SSAOBlurVRenderEffect: string;
  65794. /**
  65795. * @ignore
  65796. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65797. */
  65798. SSAOCombineRenderEffect: string;
  65799. /**
  65800. * The output strength of the SSAO post-process. Default value is 1.0.
  65801. */
  65802. totalStrength: number;
  65803. /**
  65804. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65805. */
  65806. radius: number;
  65807. /**
  65808. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65809. * Must not be equal to fallOff and superior to fallOff.
  65810. * Default value is 0.0075
  65811. */
  65812. area: number;
  65813. /**
  65814. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65815. * Must not be equal to area and inferior to area.
  65816. * Default value is 0.000001
  65817. */
  65818. fallOff: number;
  65819. /**
  65820. * The base color of the SSAO post-process
  65821. * The final result is "base + ssao" between [0, 1]
  65822. */
  65823. base: number;
  65824. private _scene;
  65825. private _depthTexture;
  65826. private _randomTexture;
  65827. private _originalColorPostProcess;
  65828. private _ssaoPostProcess;
  65829. private _blurHPostProcess;
  65830. private _blurVPostProcess;
  65831. private _ssaoCombinePostProcess;
  65832. private _firstUpdate;
  65833. /**
  65834. * Gets active scene
  65835. */
  65836. get scene(): Scene;
  65837. /**
  65838. * @constructor
  65839. * @param name - The rendering pipeline name
  65840. * @param scene - The scene linked to this pipeline
  65841. * @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 }
  65842. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65843. */
  65844. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65845. /**
  65846. * Get the class name
  65847. * @returns "SSAORenderingPipeline"
  65848. */
  65849. getClassName(): string;
  65850. /**
  65851. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65852. */
  65853. dispose(disableDepthRender?: boolean): void;
  65854. private _createBlurPostProcess;
  65855. /** @hidden */
  65856. _rebuild(): void;
  65857. private _createSSAOPostProcess;
  65858. private _createSSAOCombinePostProcess;
  65859. private _createRandomTexture;
  65860. }
  65861. }
  65862. declare module BABYLON {
  65863. /** @hidden */
  65864. export var screenSpaceReflectionPixelShader: {
  65865. name: string;
  65866. shader: string;
  65867. };
  65868. }
  65869. declare module BABYLON {
  65870. /**
  65871. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65872. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65873. */
  65874. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65875. /**
  65876. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65877. */
  65878. threshold: number;
  65879. /**
  65880. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65881. */
  65882. strength: number;
  65883. /**
  65884. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65885. */
  65886. reflectionSpecularFalloffExponent: number;
  65887. /**
  65888. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  65889. */
  65890. step: number;
  65891. /**
  65892. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65893. */
  65894. roughnessFactor: number;
  65895. private _geometryBufferRenderer;
  65896. private _enableSmoothReflections;
  65897. private _reflectionSamples;
  65898. private _smoothSteps;
  65899. /**
  65900. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65901. * @param name The name of the effect.
  65902. * @param scene The scene containing the objects to calculate reflections.
  65903. * @param options The required width/height ratio to downsize to before computing the render pass.
  65904. * @param camera The camera to apply the render pass to.
  65905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65906. * @param engine The engine which the post process will be applied. (default: current engine)
  65907. * @param reusable If the post process can be reused on the same frame. (default: false)
  65908. * @param textureType Type of textures used when performing the post process. (default: 0)
  65909. * @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)
  65910. */
  65911. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65912. /**
  65913. * Gets wether or not smoothing reflections is enabled.
  65914. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65915. */
  65916. get enableSmoothReflections(): boolean;
  65917. /**
  65918. * Sets wether or not smoothing reflections is enabled.
  65919. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65920. */
  65921. set enableSmoothReflections(enabled: boolean);
  65922. /**
  65923. * Gets the number of samples taken while computing reflections. More samples count is high,
  65924. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65925. */
  65926. get reflectionSamples(): number;
  65927. /**
  65928. * Sets the number of samples taken while computing reflections. More samples count is high,
  65929. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65930. */
  65931. set reflectionSamples(samples: number);
  65932. /**
  65933. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65934. * more the post-process will require GPU power and can generate a drop in FPS.
  65935. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65936. */
  65937. get smoothSteps(): number;
  65938. set smoothSteps(steps: number);
  65939. private _updateEffectDefines;
  65940. }
  65941. }
  65942. declare module BABYLON {
  65943. /** @hidden */
  65944. export var standardPixelShader: {
  65945. name: string;
  65946. shader: string;
  65947. };
  65948. }
  65949. declare module BABYLON {
  65950. /**
  65951. * Standard rendering pipeline
  65952. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65953. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65954. */
  65955. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65956. /**
  65957. * Public members
  65958. */
  65959. /**
  65960. * Post-process which contains the original scene color before the pipeline applies all the effects
  65961. */
  65962. originalPostProcess: Nullable<PostProcess>;
  65963. /**
  65964. * Post-process used to down scale an image x4
  65965. */
  65966. downSampleX4PostProcess: Nullable<PostProcess>;
  65967. /**
  65968. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65969. */
  65970. brightPassPostProcess: Nullable<PostProcess>;
  65971. /**
  65972. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65973. */
  65974. blurHPostProcesses: PostProcess[];
  65975. /**
  65976. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65977. */
  65978. blurVPostProcesses: PostProcess[];
  65979. /**
  65980. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65981. */
  65982. textureAdderPostProcess: Nullable<PostProcess>;
  65983. /**
  65984. * Post-process used to create volumetric lighting effect
  65985. */
  65986. volumetricLightPostProcess: Nullable<PostProcess>;
  65987. /**
  65988. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65989. */
  65990. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65991. /**
  65992. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65993. */
  65994. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65995. /**
  65996. * Post-process used to merge the volumetric light effect and the real scene color
  65997. */
  65998. volumetricLightMergePostProces: Nullable<PostProcess>;
  65999. /**
  66000. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  66001. */
  66002. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  66003. /**
  66004. * Base post-process used to calculate the average luminance of the final image for HDR
  66005. */
  66006. luminancePostProcess: Nullable<PostProcess>;
  66007. /**
  66008. * Post-processes used to create down sample post-processes in order to get
  66009. * the average luminance of the final image for HDR
  66010. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  66011. */
  66012. luminanceDownSamplePostProcesses: PostProcess[];
  66013. /**
  66014. * Post-process used to create a HDR effect (light adaptation)
  66015. */
  66016. hdrPostProcess: Nullable<PostProcess>;
  66017. /**
  66018. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  66019. */
  66020. textureAdderFinalPostProcess: Nullable<PostProcess>;
  66021. /**
  66022. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  66023. */
  66024. lensFlareFinalPostProcess: Nullable<PostProcess>;
  66025. /**
  66026. * Post-process used to merge the final HDR post-process and the real scene color
  66027. */
  66028. hdrFinalPostProcess: Nullable<PostProcess>;
  66029. /**
  66030. * Post-process used to create a lens flare effect
  66031. */
  66032. lensFlarePostProcess: Nullable<PostProcess>;
  66033. /**
  66034. * Post-process that merges the result of the lens flare post-process and the real scene color
  66035. */
  66036. lensFlareComposePostProcess: Nullable<PostProcess>;
  66037. /**
  66038. * Post-process used to create a motion blur effect
  66039. */
  66040. motionBlurPostProcess: Nullable<PostProcess>;
  66041. /**
  66042. * Post-process used to create a depth of field effect
  66043. */
  66044. depthOfFieldPostProcess: Nullable<PostProcess>;
  66045. /**
  66046. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  66047. */
  66048. fxaaPostProcess: Nullable<FxaaPostProcess>;
  66049. /**
  66050. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  66051. */
  66052. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  66053. /**
  66054. * Represents the brightness threshold in order to configure the illuminated surfaces
  66055. */
  66056. brightThreshold: number;
  66057. /**
  66058. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66059. */
  66060. blurWidth: number;
  66061. /**
  66062. * Sets if the blur for highlighted surfaces must be only horizontal
  66063. */
  66064. horizontalBlur: boolean;
  66065. /**
  66066. * Gets the overall exposure used by the pipeline
  66067. */
  66068. get exposure(): number;
  66069. /**
  66070. * Sets the overall exposure used by the pipeline
  66071. */
  66072. set exposure(value: number);
  66073. /**
  66074. * Texture used typically to simulate "dirty" on camera lens
  66075. */
  66076. lensTexture: Nullable<Texture>;
  66077. /**
  66078. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66079. */
  66080. volumetricLightCoefficient: number;
  66081. /**
  66082. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66083. */
  66084. volumetricLightPower: number;
  66085. /**
  66086. * Used the set the blur intensity to smooth the volumetric lights
  66087. */
  66088. volumetricLightBlurScale: number;
  66089. /**
  66090. * Light (spot or directional) used to generate the volumetric lights rays
  66091. * The source light must have a shadow generate so the pipeline can get its
  66092. * depth map
  66093. */
  66094. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66095. /**
  66096. * For eye adaptation, represents the minimum luminance the eye can see
  66097. */
  66098. hdrMinimumLuminance: number;
  66099. /**
  66100. * For eye adaptation, represents the decrease luminance speed
  66101. */
  66102. hdrDecreaseRate: number;
  66103. /**
  66104. * For eye adaptation, represents the increase luminance speed
  66105. */
  66106. hdrIncreaseRate: number;
  66107. /**
  66108. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66109. */
  66110. get hdrAutoExposure(): boolean;
  66111. /**
  66112. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66113. */
  66114. set hdrAutoExposure(value: boolean);
  66115. /**
  66116. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66117. */
  66118. lensColorTexture: Nullable<Texture>;
  66119. /**
  66120. * The overall strengh for the lens flare effect
  66121. */
  66122. lensFlareStrength: number;
  66123. /**
  66124. * Dispersion coefficient for lens flare ghosts
  66125. */
  66126. lensFlareGhostDispersal: number;
  66127. /**
  66128. * Main lens flare halo width
  66129. */
  66130. lensFlareHaloWidth: number;
  66131. /**
  66132. * Based on the lens distortion effect, defines how much the lens flare result
  66133. * is distorted
  66134. */
  66135. lensFlareDistortionStrength: number;
  66136. /**
  66137. * Configures the blur intensity used for for lens flare (halo)
  66138. */
  66139. lensFlareBlurWidth: number;
  66140. /**
  66141. * Lens star texture must be used to simulate rays on the flares and is available
  66142. * in the documentation
  66143. */
  66144. lensStarTexture: Nullable<Texture>;
  66145. /**
  66146. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66147. * flare effect by taking account of the dirt texture
  66148. */
  66149. lensFlareDirtTexture: Nullable<Texture>;
  66150. /**
  66151. * Represents the focal length for the depth of field effect
  66152. */
  66153. depthOfFieldDistance: number;
  66154. /**
  66155. * Represents the blur intensity for the blurred part of the depth of field effect
  66156. */
  66157. depthOfFieldBlurWidth: number;
  66158. /**
  66159. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66160. */
  66161. get motionStrength(): number;
  66162. /**
  66163. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66164. */
  66165. set motionStrength(strength: number);
  66166. /**
  66167. * Gets wether or not the motion blur post-process is object based or screen based.
  66168. */
  66169. get objectBasedMotionBlur(): boolean;
  66170. /**
  66171. * Sets wether or not the motion blur post-process should be object based or screen based
  66172. */
  66173. set objectBasedMotionBlur(value: boolean);
  66174. /**
  66175. * List of animations for the pipeline (IAnimatable implementation)
  66176. */
  66177. animations: Animation[];
  66178. /**
  66179. * Private members
  66180. */
  66181. private _scene;
  66182. private _currentDepthOfFieldSource;
  66183. private _basePostProcess;
  66184. private _fixedExposure;
  66185. private _currentExposure;
  66186. private _hdrAutoExposure;
  66187. private _hdrCurrentLuminance;
  66188. private _motionStrength;
  66189. private _isObjectBasedMotionBlur;
  66190. private _floatTextureType;
  66191. private _camerasToBeAttached;
  66192. private _ratio;
  66193. private _bloomEnabled;
  66194. private _depthOfFieldEnabled;
  66195. private _vlsEnabled;
  66196. private _lensFlareEnabled;
  66197. private _hdrEnabled;
  66198. private _motionBlurEnabled;
  66199. private _fxaaEnabled;
  66200. private _screenSpaceReflectionsEnabled;
  66201. private _motionBlurSamples;
  66202. private _volumetricLightStepsCount;
  66203. private _samples;
  66204. /**
  66205. * @ignore
  66206. * Specifies if the bloom pipeline is enabled
  66207. */
  66208. get BloomEnabled(): boolean;
  66209. set BloomEnabled(enabled: boolean);
  66210. /**
  66211. * @ignore
  66212. * Specifies if the depth of field pipeline is enabed
  66213. */
  66214. get DepthOfFieldEnabled(): boolean;
  66215. set DepthOfFieldEnabled(enabled: boolean);
  66216. /**
  66217. * @ignore
  66218. * Specifies if the lens flare pipeline is enabed
  66219. */
  66220. get LensFlareEnabled(): boolean;
  66221. set LensFlareEnabled(enabled: boolean);
  66222. /**
  66223. * @ignore
  66224. * Specifies if the HDR pipeline is enabled
  66225. */
  66226. get HDREnabled(): boolean;
  66227. set HDREnabled(enabled: boolean);
  66228. /**
  66229. * @ignore
  66230. * Specifies if the volumetric lights scattering effect is enabled
  66231. */
  66232. get VLSEnabled(): boolean;
  66233. set VLSEnabled(enabled: boolean);
  66234. /**
  66235. * @ignore
  66236. * Specifies if the motion blur effect is enabled
  66237. */
  66238. get MotionBlurEnabled(): boolean;
  66239. set MotionBlurEnabled(enabled: boolean);
  66240. /**
  66241. * Specifies if anti-aliasing is enabled
  66242. */
  66243. get fxaaEnabled(): boolean;
  66244. set fxaaEnabled(enabled: boolean);
  66245. /**
  66246. * Specifies if screen space reflections are enabled.
  66247. */
  66248. get screenSpaceReflectionsEnabled(): boolean;
  66249. set screenSpaceReflectionsEnabled(enabled: boolean);
  66250. /**
  66251. * Specifies the number of steps used to calculate the volumetric lights
  66252. * Typically in interval [50, 200]
  66253. */
  66254. get volumetricLightStepsCount(): number;
  66255. set volumetricLightStepsCount(count: number);
  66256. /**
  66257. * Specifies the number of samples used for the motion blur effect
  66258. * Typically in interval [16, 64]
  66259. */
  66260. get motionBlurSamples(): number;
  66261. set motionBlurSamples(samples: number);
  66262. /**
  66263. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66264. */
  66265. get samples(): number;
  66266. set samples(sampleCount: number);
  66267. /**
  66268. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66269. * @constructor
  66270. * @param name The rendering pipeline name
  66271. * @param scene The scene linked to this pipeline
  66272. * @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)
  66273. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66274. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66275. */
  66276. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66277. private _buildPipeline;
  66278. private _createDownSampleX4PostProcess;
  66279. private _createBrightPassPostProcess;
  66280. private _createBlurPostProcesses;
  66281. private _createTextureAdderPostProcess;
  66282. private _createVolumetricLightPostProcess;
  66283. private _createLuminancePostProcesses;
  66284. private _createHdrPostProcess;
  66285. private _createLensFlarePostProcess;
  66286. private _createDepthOfFieldPostProcess;
  66287. private _createMotionBlurPostProcess;
  66288. private _getDepthTexture;
  66289. private _disposePostProcesses;
  66290. /**
  66291. * Dispose of the pipeline and stop all post processes
  66292. */
  66293. dispose(): void;
  66294. /**
  66295. * Serialize the rendering pipeline (Used when exporting)
  66296. * @returns the serialized object
  66297. */
  66298. serialize(): any;
  66299. /**
  66300. * Parse the serialized pipeline
  66301. * @param source Source pipeline.
  66302. * @param scene The scene to load the pipeline to.
  66303. * @param rootUrl The URL of the serialized pipeline.
  66304. * @returns An instantiated pipeline from the serialized object.
  66305. */
  66306. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66307. /**
  66308. * Luminance steps
  66309. */
  66310. static LuminanceSteps: number;
  66311. }
  66312. }
  66313. declare module BABYLON {
  66314. /** @hidden */
  66315. export var tonemapPixelShader: {
  66316. name: string;
  66317. shader: string;
  66318. };
  66319. }
  66320. declare module BABYLON {
  66321. /** Defines operator used for tonemapping */
  66322. export enum TonemappingOperator {
  66323. /** Hable */
  66324. Hable = 0,
  66325. /** Reinhard */
  66326. Reinhard = 1,
  66327. /** HejiDawson */
  66328. HejiDawson = 2,
  66329. /** Photographic */
  66330. Photographic = 3
  66331. }
  66332. /**
  66333. * Defines a post process to apply tone mapping
  66334. */
  66335. export class TonemapPostProcess extends PostProcess {
  66336. private _operator;
  66337. /** Defines the required exposure adjustement */
  66338. exposureAdjustment: number;
  66339. /**
  66340. * Creates a new TonemapPostProcess
  66341. * @param name defines the name of the postprocess
  66342. * @param _operator defines the operator to use
  66343. * @param exposureAdjustment defines the required exposure adjustement
  66344. * @param camera defines the camera to use (can be null)
  66345. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66346. * @param engine defines the hosting engine (can be ignore if camera is set)
  66347. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66348. */
  66349. constructor(name: string, _operator: TonemappingOperator,
  66350. /** Defines the required exposure adjustement */
  66351. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66352. }
  66353. }
  66354. declare module BABYLON {
  66355. /** @hidden */
  66356. export var volumetricLightScatteringPixelShader: {
  66357. name: string;
  66358. shader: string;
  66359. };
  66360. }
  66361. declare module BABYLON {
  66362. /** @hidden */
  66363. export var volumetricLightScatteringPassVertexShader: {
  66364. name: string;
  66365. shader: string;
  66366. };
  66367. }
  66368. declare module BABYLON {
  66369. /** @hidden */
  66370. export var volumetricLightScatteringPassPixelShader: {
  66371. name: string;
  66372. shader: string;
  66373. };
  66374. }
  66375. declare module BABYLON {
  66376. /**
  66377. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66378. */
  66379. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66380. private _volumetricLightScatteringPass;
  66381. private _volumetricLightScatteringRTT;
  66382. private _viewPort;
  66383. private _screenCoordinates;
  66384. private _cachedDefines;
  66385. /**
  66386. * If not undefined, the mesh position is computed from the attached node position
  66387. */
  66388. attachedNode: {
  66389. position: Vector3;
  66390. };
  66391. /**
  66392. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66393. */
  66394. customMeshPosition: Vector3;
  66395. /**
  66396. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66397. */
  66398. useCustomMeshPosition: boolean;
  66399. /**
  66400. * If the post-process should inverse the light scattering direction
  66401. */
  66402. invert: boolean;
  66403. /**
  66404. * The internal mesh used by the post-process
  66405. */
  66406. mesh: Mesh;
  66407. /**
  66408. * @hidden
  66409. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66410. */
  66411. get useDiffuseColor(): boolean;
  66412. set useDiffuseColor(useDiffuseColor: boolean);
  66413. /**
  66414. * Array containing the excluded meshes not rendered in the internal pass
  66415. */
  66416. excludedMeshes: AbstractMesh[];
  66417. /**
  66418. * Controls the overall intensity of the post-process
  66419. */
  66420. exposure: number;
  66421. /**
  66422. * Dissipates each sample's contribution in range [0, 1]
  66423. */
  66424. decay: number;
  66425. /**
  66426. * Controls the overall intensity of each sample
  66427. */
  66428. weight: number;
  66429. /**
  66430. * Controls the density of each sample
  66431. */
  66432. density: number;
  66433. /**
  66434. * @constructor
  66435. * @param name The post-process name
  66436. * @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)
  66437. * @param camera The camera that the post-process will be attached to
  66438. * @param mesh The mesh used to create the light scattering
  66439. * @param samples The post-process quality, default 100
  66440. * @param samplingModeThe post-process filtering mode
  66441. * @param engine The babylon engine
  66442. * @param reusable If the post-process is reusable
  66443. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66444. */
  66445. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66446. /**
  66447. * Returns the string "VolumetricLightScatteringPostProcess"
  66448. * @returns "VolumetricLightScatteringPostProcess"
  66449. */
  66450. getClassName(): string;
  66451. private _isReady;
  66452. /**
  66453. * Sets the new light position for light scattering effect
  66454. * @param position The new custom light position
  66455. */
  66456. setCustomMeshPosition(position: Vector3): void;
  66457. /**
  66458. * Returns the light position for light scattering effect
  66459. * @return Vector3 The custom light position
  66460. */
  66461. getCustomMeshPosition(): Vector3;
  66462. /**
  66463. * Disposes the internal assets and detaches the post-process from the camera
  66464. */
  66465. dispose(camera: Camera): void;
  66466. /**
  66467. * Returns the render target texture used by the post-process
  66468. * @return the render target texture used by the post-process
  66469. */
  66470. getPass(): RenderTargetTexture;
  66471. private _meshExcluded;
  66472. private _createPass;
  66473. private _updateMeshScreenCoordinates;
  66474. /**
  66475. * Creates a default mesh for the Volumeric Light Scattering post-process
  66476. * @param name The mesh name
  66477. * @param scene The scene where to create the mesh
  66478. * @return the default mesh
  66479. */
  66480. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66481. }
  66482. }
  66483. declare module BABYLON {
  66484. interface Scene {
  66485. /** @hidden (Backing field) */
  66486. _boundingBoxRenderer: BoundingBoxRenderer;
  66487. /** @hidden (Backing field) */
  66488. _forceShowBoundingBoxes: boolean;
  66489. /**
  66490. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66491. */
  66492. forceShowBoundingBoxes: boolean;
  66493. /**
  66494. * Gets the bounding box renderer associated with the scene
  66495. * @returns a BoundingBoxRenderer
  66496. */
  66497. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66498. }
  66499. interface AbstractMesh {
  66500. /** @hidden (Backing field) */
  66501. _showBoundingBox: boolean;
  66502. /**
  66503. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66504. */
  66505. showBoundingBox: boolean;
  66506. }
  66507. /**
  66508. * Component responsible of rendering the bounding box of the meshes in a scene.
  66509. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66510. */
  66511. export class BoundingBoxRenderer implements ISceneComponent {
  66512. /**
  66513. * The component name helpfull to identify the component in the list of scene components.
  66514. */
  66515. readonly name: string;
  66516. /**
  66517. * The scene the component belongs to.
  66518. */
  66519. scene: Scene;
  66520. /**
  66521. * Color of the bounding box lines placed in front of an object
  66522. */
  66523. frontColor: Color3;
  66524. /**
  66525. * Color of the bounding box lines placed behind an object
  66526. */
  66527. backColor: Color3;
  66528. /**
  66529. * Defines if the renderer should show the back lines or not
  66530. */
  66531. showBackLines: boolean;
  66532. /**
  66533. * @hidden
  66534. */
  66535. renderList: SmartArray<BoundingBox>;
  66536. private _colorShader;
  66537. private _vertexBuffers;
  66538. private _indexBuffer;
  66539. private _fillIndexBuffer;
  66540. private _fillIndexData;
  66541. /**
  66542. * Instantiates a new bounding box renderer in a scene.
  66543. * @param scene the scene the renderer renders in
  66544. */
  66545. constructor(scene: Scene);
  66546. /**
  66547. * Registers the component in a given scene
  66548. */
  66549. register(): void;
  66550. private _evaluateSubMesh;
  66551. private _activeMesh;
  66552. private _prepareRessources;
  66553. private _createIndexBuffer;
  66554. /**
  66555. * Rebuilds the elements related to this component in case of
  66556. * context lost for instance.
  66557. */
  66558. rebuild(): void;
  66559. /**
  66560. * @hidden
  66561. */
  66562. reset(): void;
  66563. /**
  66564. * Render the bounding boxes of a specific rendering group
  66565. * @param renderingGroupId defines the rendering group to render
  66566. */
  66567. render(renderingGroupId: number): void;
  66568. /**
  66569. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66570. * @param mesh Define the mesh to render the occlusion bounding box for
  66571. */
  66572. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66573. /**
  66574. * Dispose and release the resources attached to this renderer.
  66575. */
  66576. dispose(): void;
  66577. }
  66578. }
  66579. declare module BABYLON {
  66580. interface Scene {
  66581. /** @hidden (Backing field) */
  66582. _depthRenderer: {
  66583. [id: string]: DepthRenderer;
  66584. };
  66585. /**
  66586. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66587. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66588. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66589. * @returns the created depth renderer
  66590. */
  66591. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66592. /**
  66593. * Disables a depth renderer for a given camera
  66594. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66595. */
  66596. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66597. }
  66598. /**
  66599. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66600. * in several rendering techniques.
  66601. */
  66602. export class DepthRendererSceneComponent implements ISceneComponent {
  66603. /**
  66604. * The component name helpfull to identify the component in the list of scene components.
  66605. */
  66606. readonly name: string;
  66607. /**
  66608. * The scene the component belongs to.
  66609. */
  66610. scene: Scene;
  66611. /**
  66612. * Creates a new instance of the component for the given scene
  66613. * @param scene Defines the scene to register the component in
  66614. */
  66615. constructor(scene: Scene);
  66616. /**
  66617. * Registers the component in a given scene
  66618. */
  66619. register(): void;
  66620. /**
  66621. * Rebuilds the elements related to this component in case of
  66622. * context lost for instance.
  66623. */
  66624. rebuild(): void;
  66625. /**
  66626. * Disposes the component and the associated ressources
  66627. */
  66628. dispose(): void;
  66629. private _gatherRenderTargets;
  66630. private _gatherActiveCameraRenderTargets;
  66631. }
  66632. }
  66633. declare module BABYLON {
  66634. /** @hidden */
  66635. export var outlinePixelShader: {
  66636. name: string;
  66637. shader: string;
  66638. };
  66639. }
  66640. declare module BABYLON {
  66641. /** @hidden */
  66642. export var outlineVertexShader: {
  66643. name: string;
  66644. shader: string;
  66645. };
  66646. }
  66647. declare module BABYLON {
  66648. interface Scene {
  66649. /** @hidden */
  66650. _outlineRenderer: OutlineRenderer;
  66651. /**
  66652. * Gets the outline renderer associated with the scene
  66653. * @returns a OutlineRenderer
  66654. */
  66655. getOutlineRenderer(): OutlineRenderer;
  66656. }
  66657. interface AbstractMesh {
  66658. /** @hidden (Backing field) */
  66659. _renderOutline: boolean;
  66660. /**
  66661. * Gets or sets a boolean indicating if the outline must be rendered as well
  66662. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66663. */
  66664. renderOutline: boolean;
  66665. /** @hidden (Backing field) */
  66666. _renderOverlay: boolean;
  66667. /**
  66668. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66669. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66670. */
  66671. renderOverlay: boolean;
  66672. }
  66673. /**
  66674. * This class is responsible to draw bothe outline/overlay of meshes.
  66675. * It should not be used directly but through the available method on mesh.
  66676. */
  66677. export class OutlineRenderer implements ISceneComponent {
  66678. /**
  66679. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66680. */
  66681. private static _StencilReference;
  66682. /**
  66683. * The name of the component. Each component must have a unique name.
  66684. */
  66685. name: string;
  66686. /**
  66687. * The scene the component belongs to.
  66688. */
  66689. scene: Scene;
  66690. /**
  66691. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66692. */
  66693. zOffset: number;
  66694. private _engine;
  66695. private _effect;
  66696. private _cachedDefines;
  66697. private _savedDepthWrite;
  66698. /**
  66699. * Instantiates a new outline renderer. (There could be only one per scene).
  66700. * @param scene Defines the scene it belongs to
  66701. */
  66702. constructor(scene: Scene);
  66703. /**
  66704. * Register the component to one instance of a scene.
  66705. */
  66706. register(): void;
  66707. /**
  66708. * Rebuilds the elements related to this component in case of
  66709. * context lost for instance.
  66710. */
  66711. rebuild(): void;
  66712. /**
  66713. * Disposes the component and the associated ressources.
  66714. */
  66715. dispose(): void;
  66716. /**
  66717. * Renders the outline in the canvas.
  66718. * @param subMesh Defines the sumesh to render
  66719. * @param batch Defines the batch of meshes in case of instances
  66720. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66721. */
  66722. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66723. /**
  66724. * Returns whether or not the outline renderer is ready for a given submesh.
  66725. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66726. * @param subMesh Defines the submesh to check readyness for
  66727. * @param useInstances Defines wheter wee are trying to render instances or not
  66728. * @returns true if ready otherwise false
  66729. */
  66730. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66731. private _beforeRenderingMesh;
  66732. private _afterRenderingMesh;
  66733. }
  66734. }
  66735. declare module BABYLON {
  66736. /**
  66737. * Defines the basic options interface of a Sprite Frame Source Size.
  66738. */
  66739. export interface ISpriteJSONSpriteSourceSize {
  66740. /**
  66741. * number of the original width of the Frame
  66742. */
  66743. w: number;
  66744. /**
  66745. * number of the original height of the Frame
  66746. */
  66747. h: number;
  66748. }
  66749. /**
  66750. * Defines the basic options interface of a Sprite Frame Data.
  66751. */
  66752. export interface ISpriteJSONSpriteFrameData {
  66753. /**
  66754. * number of the x offset of the Frame
  66755. */
  66756. x: number;
  66757. /**
  66758. * number of the y offset of the Frame
  66759. */
  66760. y: number;
  66761. /**
  66762. * number of the width of the Frame
  66763. */
  66764. w: number;
  66765. /**
  66766. * number of the height of the Frame
  66767. */
  66768. h: number;
  66769. }
  66770. /**
  66771. * Defines the basic options interface of a JSON Sprite.
  66772. */
  66773. export interface ISpriteJSONSprite {
  66774. /**
  66775. * string name of the Frame
  66776. */
  66777. filename: string;
  66778. /**
  66779. * ISpriteJSONSpriteFrame basic object of the frame data
  66780. */
  66781. frame: ISpriteJSONSpriteFrameData;
  66782. /**
  66783. * boolean to flag is the frame was rotated.
  66784. */
  66785. rotated: boolean;
  66786. /**
  66787. * boolean to flag is the frame was trimmed.
  66788. */
  66789. trimmed: boolean;
  66790. /**
  66791. * ISpriteJSONSpriteFrame basic object of the source data
  66792. */
  66793. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66794. /**
  66795. * ISpriteJSONSpriteFrame basic object of the source data
  66796. */
  66797. sourceSize: ISpriteJSONSpriteSourceSize;
  66798. }
  66799. /**
  66800. * Defines the basic options interface of a JSON atlas.
  66801. */
  66802. export interface ISpriteJSONAtlas {
  66803. /**
  66804. * Array of objects that contain the frame data.
  66805. */
  66806. frames: Array<ISpriteJSONSprite>;
  66807. /**
  66808. * object basic object containing the sprite meta data.
  66809. */
  66810. meta?: object;
  66811. }
  66812. }
  66813. declare module BABYLON {
  66814. /** @hidden */
  66815. export var spriteMapPixelShader: {
  66816. name: string;
  66817. shader: string;
  66818. };
  66819. }
  66820. declare module BABYLON {
  66821. /** @hidden */
  66822. export var spriteMapVertexShader: {
  66823. name: string;
  66824. shader: string;
  66825. };
  66826. }
  66827. declare module BABYLON {
  66828. /**
  66829. * Defines the basic options interface of a SpriteMap
  66830. */
  66831. export interface ISpriteMapOptions {
  66832. /**
  66833. * Vector2 of the number of cells in the grid.
  66834. */
  66835. stageSize?: Vector2;
  66836. /**
  66837. * Vector2 of the size of the output plane in World Units.
  66838. */
  66839. outputSize?: Vector2;
  66840. /**
  66841. * Vector3 of the position of the output plane in World Units.
  66842. */
  66843. outputPosition?: Vector3;
  66844. /**
  66845. * Vector3 of the rotation of the output plane.
  66846. */
  66847. outputRotation?: Vector3;
  66848. /**
  66849. * number of layers that the system will reserve in resources.
  66850. */
  66851. layerCount?: number;
  66852. /**
  66853. * number of max animation frames a single cell will reserve in resources.
  66854. */
  66855. maxAnimationFrames?: number;
  66856. /**
  66857. * number cell index of the base tile when the system compiles.
  66858. */
  66859. baseTile?: number;
  66860. /**
  66861. * boolean flip the sprite after its been repositioned by the framing data.
  66862. */
  66863. flipU?: boolean;
  66864. /**
  66865. * Vector3 scalar of the global RGB values of the SpriteMap.
  66866. */
  66867. colorMultiply?: Vector3;
  66868. }
  66869. /**
  66870. * Defines the IDisposable interface in order to be cleanable from resources.
  66871. */
  66872. export interface ISpriteMap extends IDisposable {
  66873. /**
  66874. * String name of the SpriteMap.
  66875. */
  66876. name: string;
  66877. /**
  66878. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66879. */
  66880. atlasJSON: ISpriteJSONAtlas;
  66881. /**
  66882. * Texture of the SpriteMap.
  66883. */
  66884. spriteSheet: Texture;
  66885. /**
  66886. * The parameters to initialize the SpriteMap with.
  66887. */
  66888. options: ISpriteMapOptions;
  66889. }
  66890. /**
  66891. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66892. */
  66893. export class SpriteMap implements ISpriteMap {
  66894. /** The Name of the spriteMap */
  66895. name: string;
  66896. /** The JSON file with the frame and meta data */
  66897. atlasJSON: ISpriteJSONAtlas;
  66898. /** The systems Sprite Sheet Texture */
  66899. spriteSheet: Texture;
  66900. /** Arguments passed with the Constructor */
  66901. options: ISpriteMapOptions;
  66902. /** Public Sprite Storage array, parsed from atlasJSON */
  66903. sprites: Array<ISpriteJSONSprite>;
  66904. /** Returns the Number of Sprites in the System */
  66905. get spriteCount(): number;
  66906. /** Returns the Position of Output Plane*/
  66907. get position(): Vector3;
  66908. /** Returns the Position of Output Plane*/
  66909. set position(v: Vector3);
  66910. /** Returns the Rotation of Output Plane*/
  66911. get rotation(): Vector3;
  66912. /** Returns the Rotation of Output Plane*/
  66913. set rotation(v: Vector3);
  66914. /** Sets the AnimationMap*/
  66915. get animationMap(): RawTexture;
  66916. /** Sets the AnimationMap*/
  66917. set animationMap(v: RawTexture);
  66918. /** Scene that the SpriteMap was created in */
  66919. private _scene;
  66920. /** Texture Buffer of Float32 that holds tile frame data*/
  66921. private _frameMap;
  66922. /** Texture Buffers of Float32 that holds tileMap data*/
  66923. private _tileMaps;
  66924. /** Texture Buffer of Float32 that holds Animation Data*/
  66925. private _animationMap;
  66926. /** Custom ShaderMaterial Central to the System*/
  66927. private _material;
  66928. /** Custom ShaderMaterial Central to the System*/
  66929. private _output;
  66930. /** Systems Time Ticker*/
  66931. private _time;
  66932. /**
  66933. * Creates a new SpriteMap
  66934. * @param name defines the SpriteMaps Name
  66935. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66936. * @param spriteSheet is the Texture that the Sprites are on.
  66937. * @param options a basic deployment configuration
  66938. * @param scene The Scene that the map is deployed on
  66939. */
  66940. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66941. /**
  66942. * Returns tileID location
  66943. * @returns Vector2 the cell position ID
  66944. */
  66945. getTileID(): Vector2;
  66946. /**
  66947. * Gets the UV location of the mouse over the SpriteMap.
  66948. * @returns Vector2 the UV position of the mouse interaction
  66949. */
  66950. getMousePosition(): Vector2;
  66951. /**
  66952. * Creates the "frame" texture Buffer
  66953. * -------------------------------------
  66954. * Structure of frames
  66955. * "filename": "Falling-Water-2.png",
  66956. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66957. * "rotated": true,
  66958. * "trimmed": true,
  66959. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66960. * "sourceSize": {"w":32,"h":32}
  66961. * @returns RawTexture of the frameMap
  66962. */
  66963. private _createFrameBuffer;
  66964. /**
  66965. * Creates the tileMap texture Buffer
  66966. * @param buffer normally and array of numbers, or a false to generate from scratch
  66967. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66968. * @returns RawTexture of the tileMap
  66969. */
  66970. private _createTileBuffer;
  66971. /**
  66972. * Modifies the data of the tileMaps
  66973. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66974. * @param pos is the iVector2 Coordinates of the Tile
  66975. * @param tile The SpriteIndex of the new Tile
  66976. */
  66977. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66978. /**
  66979. * Creates the animationMap texture Buffer
  66980. * @param buffer normally and array of numbers, or a false to generate from scratch
  66981. * @returns RawTexture of the animationMap
  66982. */
  66983. private _createTileAnimationBuffer;
  66984. /**
  66985. * Modifies the data of the animationMap
  66986. * @param cellID is the Index of the Sprite
  66987. * @param _frame is the target Animation frame
  66988. * @param toCell is the Target Index of the next frame of the animation
  66989. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66990. * @param speed is a global scalar of the time variable on the map.
  66991. */
  66992. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66993. /**
  66994. * Exports the .tilemaps file
  66995. */
  66996. saveTileMaps(): void;
  66997. /**
  66998. * Imports the .tilemaps file
  66999. * @param url of the .tilemaps file
  67000. */
  67001. loadTileMaps(url: string): void;
  67002. /**
  67003. * Release associated resources
  67004. */
  67005. dispose(): void;
  67006. }
  67007. }
  67008. declare module BABYLON {
  67009. /**
  67010. * Class used to manage multiple sprites of different sizes on the same spritesheet
  67011. * @see http://doc.babylonjs.com/babylon101/sprites
  67012. */
  67013. export class SpritePackedManager extends SpriteManager {
  67014. /** defines the packed manager's name */
  67015. name: string;
  67016. /**
  67017. * Creates a new sprite manager from a packed sprite sheet
  67018. * @param name defines the manager's name
  67019. * @param imgUrl defines the sprite sheet url
  67020. * @param capacity defines the maximum allowed number of sprites
  67021. * @param scene defines the hosting scene
  67022. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  67023. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  67024. * @param samplingMode defines the smapling mode to use with spritesheet
  67025. * @param fromPacked set to true; do not alter
  67026. */
  67027. constructor(
  67028. /** defines the packed manager's name */
  67029. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  67030. }
  67031. }
  67032. declare module BABYLON {
  67033. /**
  67034. * Defines the list of states available for a task inside a AssetsManager
  67035. */
  67036. export enum AssetTaskState {
  67037. /**
  67038. * Initialization
  67039. */
  67040. INIT = 0,
  67041. /**
  67042. * Running
  67043. */
  67044. RUNNING = 1,
  67045. /**
  67046. * Done
  67047. */
  67048. DONE = 2,
  67049. /**
  67050. * Error
  67051. */
  67052. ERROR = 3
  67053. }
  67054. /**
  67055. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  67056. */
  67057. export abstract class AbstractAssetTask {
  67058. /**
  67059. * Task name
  67060. */ name: string;
  67061. /**
  67062. * Callback called when the task is successful
  67063. */
  67064. onSuccess: (task: any) => void;
  67065. /**
  67066. * Callback called when the task is not successful
  67067. */
  67068. onError: (task: any, message?: string, exception?: any) => void;
  67069. /**
  67070. * Creates a new AssetsManager
  67071. * @param name defines the name of the task
  67072. */
  67073. constructor(
  67074. /**
  67075. * Task name
  67076. */ name: string);
  67077. private _isCompleted;
  67078. private _taskState;
  67079. private _errorObject;
  67080. /**
  67081. * Get if the task is completed
  67082. */
  67083. get isCompleted(): boolean;
  67084. /**
  67085. * Gets the current state of the task
  67086. */
  67087. get taskState(): AssetTaskState;
  67088. /**
  67089. * Gets the current error object (if task is in error)
  67090. */
  67091. get errorObject(): {
  67092. message?: string;
  67093. exception?: any;
  67094. };
  67095. /**
  67096. * Internal only
  67097. * @hidden
  67098. */
  67099. _setErrorObject(message?: string, exception?: any): void;
  67100. /**
  67101. * Execute the current task
  67102. * @param scene defines the scene where you want your assets to be loaded
  67103. * @param onSuccess is a callback called when the task is successfully executed
  67104. * @param onError is a callback called if an error occurs
  67105. */
  67106. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67107. /**
  67108. * Execute the current task
  67109. * @param scene defines the scene where you want your assets to be loaded
  67110. * @param onSuccess is a callback called when the task is successfully executed
  67111. * @param onError is a callback called if an error occurs
  67112. */
  67113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67114. /**
  67115. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67116. * This can be used with failed tasks that have the reason for failure fixed.
  67117. */
  67118. reset(): void;
  67119. private onErrorCallback;
  67120. private onDoneCallback;
  67121. }
  67122. /**
  67123. * Define the interface used by progress events raised during assets loading
  67124. */
  67125. export interface IAssetsProgressEvent {
  67126. /**
  67127. * Defines the number of remaining tasks to process
  67128. */
  67129. remainingCount: number;
  67130. /**
  67131. * Defines the total number of tasks
  67132. */
  67133. totalCount: number;
  67134. /**
  67135. * Defines the task that was just processed
  67136. */
  67137. task: AbstractAssetTask;
  67138. }
  67139. /**
  67140. * Class used to share progress information about assets loading
  67141. */
  67142. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67143. /**
  67144. * Defines the number of remaining tasks to process
  67145. */
  67146. remainingCount: number;
  67147. /**
  67148. * Defines the total number of tasks
  67149. */
  67150. totalCount: number;
  67151. /**
  67152. * Defines the task that was just processed
  67153. */
  67154. task: AbstractAssetTask;
  67155. /**
  67156. * Creates a AssetsProgressEvent
  67157. * @param remainingCount defines the number of remaining tasks to process
  67158. * @param totalCount defines the total number of tasks
  67159. * @param task defines the task that was just processed
  67160. */
  67161. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67162. }
  67163. /**
  67164. * Define a task used by AssetsManager to load meshes
  67165. */
  67166. export class MeshAssetTask extends AbstractAssetTask {
  67167. /**
  67168. * Defines the name of the task
  67169. */
  67170. name: string;
  67171. /**
  67172. * Defines the list of mesh's names you want to load
  67173. */
  67174. meshesNames: any;
  67175. /**
  67176. * Defines the root url to use as a base to load your meshes and associated resources
  67177. */
  67178. rootUrl: string;
  67179. /**
  67180. * Defines the filename of the scene to load from
  67181. */
  67182. sceneFilename: string;
  67183. /**
  67184. * Gets the list of loaded meshes
  67185. */
  67186. loadedMeshes: Array<AbstractMesh>;
  67187. /**
  67188. * Gets the list of loaded particle systems
  67189. */
  67190. loadedParticleSystems: Array<IParticleSystem>;
  67191. /**
  67192. * Gets the list of loaded skeletons
  67193. */
  67194. loadedSkeletons: Array<Skeleton>;
  67195. /**
  67196. * Gets the list of loaded animation groups
  67197. */
  67198. loadedAnimationGroups: Array<AnimationGroup>;
  67199. /**
  67200. * Callback called when the task is successful
  67201. */
  67202. onSuccess: (task: MeshAssetTask) => void;
  67203. /**
  67204. * Callback called when the task is successful
  67205. */
  67206. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67207. /**
  67208. * Creates a new MeshAssetTask
  67209. * @param name defines the name of the task
  67210. * @param meshesNames defines the list of mesh's names you want to load
  67211. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67212. * @param sceneFilename defines the filename of the scene to load from
  67213. */
  67214. constructor(
  67215. /**
  67216. * Defines the name of the task
  67217. */
  67218. name: string,
  67219. /**
  67220. * Defines the list of mesh's names you want to load
  67221. */
  67222. meshesNames: any,
  67223. /**
  67224. * Defines the root url to use as a base to load your meshes and associated resources
  67225. */
  67226. rootUrl: string,
  67227. /**
  67228. * Defines the filename of the scene to load from
  67229. */
  67230. sceneFilename: string);
  67231. /**
  67232. * Execute the current task
  67233. * @param scene defines the scene where you want your assets to be loaded
  67234. * @param onSuccess is a callback called when the task is successfully executed
  67235. * @param onError is a callback called if an error occurs
  67236. */
  67237. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67238. }
  67239. /**
  67240. * Define a task used by AssetsManager to load text content
  67241. */
  67242. export class TextFileAssetTask extends AbstractAssetTask {
  67243. /**
  67244. * Defines the name of the task
  67245. */
  67246. name: string;
  67247. /**
  67248. * Defines the location of the file to load
  67249. */
  67250. url: string;
  67251. /**
  67252. * Gets the loaded text string
  67253. */
  67254. text: string;
  67255. /**
  67256. * Callback called when the task is successful
  67257. */
  67258. onSuccess: (task: TextFileAssetTask) => void;
  67259. /**
  67260. * Callback called when the task is successful
  67261. */
  67262. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67263. /**
  67264. * Creates a new TextFileAssetTask object
  67265. * @param name defines the name of the task
  67266. * @param url defines the location of the file to load
  67267. */
  67268. constructor(
  67269. /**
  67270. * Defines the name of the task
  67271. */
  67272. name: string,
  67273. /**
  67274. * Defines the location of the file to load
  67275. */
  67276. url: string);
  67277. /**
  67278. * Execute the current task
  67279. * @param scene defines the scene where you want your assets to be loaded
  67280. * @param onSuccess is a callback called when the task is successfully executed
  67281. * @param onError is a callback called if an error occurs
  67282. */
  67283. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67284. }
  67285. /**
  67286. * Define a task used by AssetsManager to load binary data
  67287. */
  67288. export class BinaryFileAssetTask extends AbstractAssetTask {
  67289. /**
  67290. * Defines the name of the task
  67291. */
  67292. name: string;
  67293. /**
  67294. * Defines the location of the file to load
  67295. */
  67296. url: string;
  67297. /**
  67298. * Gets the lodaded data (as an array buffer)
  67299. */
  67300. data: ArrayBuffer;
  67301. /**
  67302. * Callback called when the task is successful
  67303. */
  67304. onSuccess: (task: BinaryFileAssetTask) => void;
  67305. /**
  67306. * Callback called when the task is successful
  67307. */
  67308. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67309. /**
  67310. * Creates a new BinaryFileAssetTask object
  67311. * @param name defines the name of the new task
  67312. * @param url defines the location of the file to load
  67313. */
  67314. constructor(
  67315. /**
  67316. * Defines the name of the task
  67317. */
  67318. name: string,
  67319. /**
  67320. * Defines the location of the file to load
  67321. */
  67322. url: string);
  67323. /**
  67324. * Execute the current task
  67325. * @param scene defines the scene where you want your assets to be loaded
  67326. * @param onSuccess is a callback called when the task is successfully executed
  67327. * @param onError is a callback called if an error occurs
  67328. */
  67329. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67330. }
  67331. /**
  67332. * Define a task used by AssetsManager to load images
  67333. */
  67334. export class ImageAssetTask extends AbstractAssetTask {
  67335. /**
  67336. * Defines the name of the task
  67337. */
  67338. name: string;
  67339. /**
  67340. * Defines the location of the image to load
  67341. */
  67342. url: string;
  67343. /**
  67344. * Gets the loaded images
  67345. */
  67346. image: HTMLImageElement;
  67347. /**
  67348. * Callback called when the task is successful
  67349. */
  67350. onSuccess: (task: ImageAssetTask) => void;
  67351. /**
  67352. * Callback called when the task is successful
  67353. */
  67354. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67355. /**
  67356. * Creates a new ImageAssetTask
  67357. * @param name defines the name of the task
  67358. * @param url defines the location of the image to load
  67359. */
  67360. constructor(
  67361. /**
  67362. * Defines the name of the task
  67363. */
  67364. name: string,
  67365. /**
  67366. * Defines the location of the image to load
  67367. */
  67368. url: string);
  67369. /**
  67370. * Execute the current task
  67371. * @param scene defines the scene where you want your assets to be loaded
  67372. * @param onSuccess is a callback called when the task is successfully executed
  67373. * @param onError is a callback called if an error occurs
  67374. */
  67375. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67376. }
  67377. /**
  67378. * Defines the interface used by texture loading tasks
  67379. */
  67380. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67381. /**
  67382. * Gets the loaded texture
  67383. */
  67384. texture: TEX;
  67385. }
  67386. /**
  67387. * Define a task used by AssetsManager to load 2D textures
  67388. */
  67389. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67390. /**
  67391. * Defines the name of the task
  67392. */
  67393. name: string;
  67394. /**
  67395. * Defines the location of the file to load
  67396. */
  67397. url: string;
  67398. /**
  67399. * Defines if mipmap should not be generated (default is false)
  67400. */
  67401. noMipmap?: boolean | undefined;
  67402. /**
  67403. * Defines if texture must be inverted on Y axis (default is false)
  67404. */
  67405. invertY?: boolean | undefined;
  67406. /**
  67407. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67408. */
  67409. samplingMode: number;
  67410. /**
  67411. * Gets the loaded texture
  67412. */
  67413. texture: Texture;
  67414. /**
  67415. * Callback called when the task is successful
  67416. */
  67417. onSuccess: (task: TextureAssetTask) => void;
  67418. /**
  67419. * Callback called when the task is successful
  67420. */
  67421. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67422. /**
  67423. * Creates a new TextureAssetTask object
  67424. * @param name defines the name of the task
  67425. * @param url defines the location of the file to load
  67426. * @param noMipmap defines if mipmap should not be generated (default is false)
  67427. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67428. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67429. */
  67430. constructor(
  67431. /**
  67432. * Defines the name of the task
  67433. */
  67434. name: string,
  67435. /**
  67436. * Defines the location of the file to load
  67437. */
  67438. url: string,
  67439. /**
  67440. * Defines if mipmap should not be generated (default is false)
  67441. */
  67442. noMipmap?: boolean | undefined,
  67443. /**
  67444. * Defines if texture must be inverted on Y axis (default is false)
  67445. */
  67446. invertY?: boolean | undefined,
  67447. /**
  67448. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67449. */
  67450. samplingMode?: number);
  67451. /**
  67452. * Execute the current task
  67453. * @param scene defines the scene where you want your assets to be loaded
  67454. * @param onSuccess is a callback called when the task is successfully executed
  67455. * @param onError is a callback called if an error occurs
  67456. */
  67457. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67458. }
  67459. /**
  67460. * Define a task used by AssetsManager to load cube textures
  67461. */
  67462. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67463. /**
  67464. * Defines the name of the task
  67465. */
  67466. name: string;
  67467. /**
  67468. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67469. */
  67470. url: string;
  67471. /**
  67472. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67473. */
  67474. extensions?: string[] | undefined;
  67475. /**
  67476. * Defines if mipmaps should not be generated (default is false)
  67477. */
  67478. noMipmap?: boolean | undefined;
  67479. /**
  67480. * Defines the explicit list of files (undefined by default)
  67481. */
  67482. files?: string[] | undefined;
  67483. /**
  67484. * Gets the loaded texture
  67485. */
  67486. texture: CubeTexture;
  67487. /**
  67488. * Callback called when the task is successful
  67489. */
  67490. onSuccess: (task: CubeTextureAssetTask) => void;
  67491. /**
  67492. * Callback called when the task is successful
  67493. */
  67494. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67495. /**
  67496. * Creates a new CubeTextureAssetTask
  67497. * @param name defines the name of the task
  67498. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67499. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67500. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67501. * @param files defines the explicit list of files (undefined by default)
  67502. */
  67503. constructor(
  67504. /**
  67505. * Defines the name of the task
  67506. */
  67507. name: string,
  67508. /**
  67509. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67510. */
  67511. url: string,
  67512. /**
  67513. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67514. */
  67515. extensions?: string[] | undefined,
  67516. /**
  67517. * Defines if mipmaps should not be generated (default is false)
  67518. */
  67519. noMipmap?: boolean | undefined,
  67520. /**
  67521. * Defines the explicit list of files (undefined by default)
  67522. */
  67523. files?: string[] | undefined);
  67524. /**
  67525. * Execute the current task
  67526. * @param scene defines the scene where you want your assets to be loaded
  67527. * @param onSuccess is a callback called when the task is successfully executed
  67528. * @param onError is a callback called if an error occurs
  67529. */
  67530. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67531. }
  67532. /**
  67533. * Define a task used by AssetsManager to load HDR cube textures
  67534. */
  67535. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67536. /**
  67537. * Defines the name of the task
  67538. */
  67539. name: string;
  67540. /**
  67541. * Defines the location of the file to load
  67542. */
  67543. url: string;
  67544. /**
  67545. * Defines the desired size (the more it increases the longer the generation will be)
  67546. */
  67547. size: number;
  67548. /**
  67549. * Defines if mipmaps should not be generated (default is false)
  67550. */
  67551. noMipmap: boolean;
  67552. /**
  67553. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67554. */
  67555. generateHarmonics: boolean;
  67556. /**
  67557. * 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)
  67558. */
  67559. gammaSpace: boolean;
  67560. /**
  67561. * Internal Use Only
  67562. */
  67563. reserved: boolean;
  67564. /**
  67565. * Gets the loaded texture
  67566. */
  67567. texture: HDRCubeTexture;
  67568. /**
  67569. * Callback called when the task is successful
  67570. */
  67571. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67572. /**
  67573. * Callback called when the task is successful
  67574. */
  67575. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67576. /**
  67577. * Creates a new HDRCubeTextureAssetTask object
  67578. * @param name defines the name of the task
  67579. * @param url defines the location of the file to load
  67580. * @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.
  67581. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67582. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67583. * @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)
  67584. * @param reserved Internal use only
  67585. */
  67586. constructor(
  67587. /**
  67588. * Defines the name of the task
  67589. */
  67590. name: string,
  67591. /**
  67592. * Defines the location of the file to load
  67593. */
  67594. url: string,
  67595. /**
  67596. * Defines the desired size (the more it increases the longer the generation will be)
  67597. */
  67598. size: number,
  67599. /**
  67600. * Defines if mipmaps should not be generated (default is false)
  67601. */
  67602. noMipmap?: boolean,
  67603. /**
  67604. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67605. */
  67606. generateHarmonics?: boolean,
  67607. /**
  67608. * 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)
  67609. */
  67610. gammaSpace?: boolean,
  67611. /**
  67612. * Internal Use Only
  67613. */
  67614. reserved?: boolean);
  67615. /**
  67616. * Execute the current task
  67617. * @param scene defines the scene where you want your assets to be loaded
  67618. * @param onSuccess is a callback called when the task is successfully executed
  67619. * @param onError is a callback called if an error occurs
  67620. */
  67621. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67622. }
  67623. /**
  67624. * Define a task used by AssetsManager to load Equirectangular cube textures
  67625. */
  67626. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67627. /**
  67628. * Defines the name of the task
  67629. */
  67630. name: string;
  67631. /**
  67632. * Defines the location of the file to load
  67633. */
  67634. url: string;
  67635. /**
  67636. * Defines the desired size (the more it increases the longer the generation will be)
  67637. */
  67638. size: number;
  67639. /**
  67640. * Defines if mipmaps should not be generated (default is false)
  67641. */
  67642. noMipmap: boolean;
  67643. /**
  67644. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67645. * but the standard material would require them in Gamma space) (default is true)
  67646. */
  67647. gammaSpace: boolean;
  67648. /**
  67649. * Gets the loaded texture
  67650. */
  67651. texture: EquiRectangularCubeTexture;
  67652. /**
  67653. * Callback called when the task is successful
  67654. */
  67655. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67656. /**
  67657. * Callback called when the task is successful
  67658. */
  67659. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67660. /**
  67661. * Creates a new EquiRectangularCubeTextureAssetTask object
  67662. * @param name defines the name of the task
  67663. * @param url defines the location of the file to load
  67664. * @param size defines the desired size (the more it increases the longer the generation will be)
  67665. * If the size is omitted this implies you are using a preprocessed cubemap.
  67666. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67667. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67668. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67669. * (default is true)
  67670. */
  67671. constructor(
  67672. /**
  67673. * Defines the name of the task
  67674. */
  67675. name: string,
  67676. /**
  67677. * Defines the location of the file to load
  67678. */
  67679. url: string,
  67680. /**
  67681. * Defines the desired size (the more it increases the longer the generation will be)
  67682. */
  67683. size: number,
  67684. /**
  67685. * Defines if mipmaps should not be generated (default is false)
  67686. */
  67687. noMipmap?: boolean,
  67688. /**
  67689. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67690. * but the standard material would require them in Gamma space) (default is true)
  67691. */
  67692. gammaSpace?: boolean);
  67693. /**
  67694. * Execute the current task
  67695. * @param scene defines the scene where you want your assets to be loaded
  67696. * @param onSuccess is a callback called when the task is successfully executed
  67697. * @param onError is a callback called if an error occurs
  67698. */
  67699. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67700. }
  67701. /**
  67702. * This class can be used to easily import assets into a scene
  67703. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67704. */
  67705. export class AssetsManager {
  67706. private _scene;
  67707. private _isLoading;
  67708. protected _tasks: AbstractAssetTask[];
  67709. protected _waitingTasksCount: number;
  67710. protected _totalTasksCount: number;
  67711. /**
  67712. * Callback called when all tasks are processed
  67713. */
  67714. onFinish: (tasks: AbstractAssetTask[]) => void;
  67715. /**
  67716. * Callback called when a task is successful
  67717. */
  67718. onTaskSuccess: (task: AbstractAssetTask) => void;
  67719. /**
  67720. * Callback called when a task had an error
  67721. */
  67722. onTaskError: (task: AbstractAssetTask) => void;
  67723. /**
  67724. * Callback called when a task is done (whatever the result is)
  67725. */
  67726. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67727. /**
  67728. * Observable called when all tasks are processed
  67729. */
  67730. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67731. /**
  67732. * Observable called when a task had an error
  67733. */
  67734. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67735. /**
  67736. * Observable called when all tasks were executed
  67737. */
  67738. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67739. /**
  67740. * Observable called when a task is done (whatever the result is)
  67741. */
  67742. onProgressObservable: Observable<IAssetsProgressEvent>;
  67743. /**
  67744. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67745. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67746. */
  67747. useDefaultLoadingScreen: boolean;
  67748. /**
  67749. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67750. * when all assets have been downloaded.
  67751. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67752. */
  67753. autoHideLoadingUI: boolean;
  67754. /**
  67755. * Creates a new AssetsManager
  67756. * @param scene defines the scene to work on
  67757. */
  67758. constructor(scene: Scene);
  67759. /**
  67760. * Add a MeshAssetTask to the list of active tasks
  67761. * @param taskName defines the name of the new task
  67762. * @param meshesNames defines the name of meshes to load
  67763. * @param rootUrl defines the root url to use to locate files
  67764. * @param sceneFilename defines the filename of the scene file
  67765. * @returns a new MeshAssetTask object
  67766. */
  67767. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67768. /**
  67769. * Add a TextFileAssetTask to the list of active tasks
  67770. * @param taskName defines the name of the new task
  67771. * @param url defines the url of the file to load
  67772. * @returns a new TextFileAssetTask object
  67773. */
  67774. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67775. /**
  67776. * Add a BinaryFileAssetTask to the list of active tasks
  67777. * @param taskName defines the name of the new task
  67778. * @param url defines the url of the file to load
  67779. * @returns a new BinaryFileAssetTask object
  67780. */
  67781. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67782. /**
  67783. * Add a ImageAssetTask to the list of active tasks
  67784. * @param taskName defines the name of the new task
  67785. * @param url defines the url of the file to load
  67786. * @returns a new ImageAssetTask object
  67787. */
  67788. addImageTask(taskName: string, url: string): ImageAssetTask;
  67789. /**
  67790. * Add a TextureAssetTask to the list of active tasks
  67791. * @param taskName defines the name of the new task
  67792. * @param url defines the url of the file to load
  67793. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67794. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67795. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67796. * @returns a new TextureAssetTask object
  67797. */
  67798. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67799. /**
  67800. * Add a CubeTextureAssetTask to the list of active tasks
  67801. * @param taskName defines the name of the new task
  67802. * @param url defines the url of the file to load
  67803. * @param extensions defines the extension to use to load the cube map (can be null)
  67804. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67805. * @param files defines the list of files to load (can be null)
  67806. * @returns a new CubeTextureAssetTask object
  67807. */
  67808. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67809. /**
  67810. *
  67811. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67812. * @param taskName defines the name of the new task
  67813. * @param url defines the url of the file to load
  67814. * @param size defines the size you want for the cubemap (can be null)
  67815. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67816. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67817. * @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)
  67818. * @param reserved Internal use only
  67819. * @returns a new HDRCubeTextureAssetTask object
  67820. */
  67821. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67822. /**
  67823. *
  67824. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67825. * @param taskName defines the name of the new task
  67826. * @param url defines the url of the file to load
  67827. * @param size defines the size you want for the cubemap (can be null)
  67828. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67829. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67830. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67831. * @returns a new EquiRectangularCubeTextureAssetTask object
  67832. */
  67833. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67834. /**
  67835. * Remove a task from the assets manager.
  67836. * @param task the task to remove
  67837. */
  67838. removeTask(task: AbstractAssetTask): void;
  67839. private _decreaseWaitingTasksCount;
  67840. private _runTask;
  67841. /**
  67842. * Reset the AssetsManager and remove all tasks
  67843. * @return the current instance of the AssetsManager
  67844. */
  67845. reset(): AssetsManager;
  67846. /**
  67847. * Start the loading process
  67848. * @return the current instance of the AssetsManager
  67849. */
  67850. load(): AssetsManager;
  67851. /**
  67852. * Start the loading process as an async operation
  67853. * @return a promise returning the list of failed tasks
  67854. */
  67855. loadAsync(): Promise<void>;
  67856. }
  67857. }
  67858. declare module BABYLON {
  67859. /**
  67860. * Wrapper class for promise with external resolve and reject.
  67861. */
  67862. export class Deferred<T> {
  67863. /**
  67864. * The promise associated with this deferred object.
  67865. */
  67866. readonly promise: Promise<T>;
  67867. private _resolve;
  67868. private _reject;
  67869. /**
  67870. * The resolve method of the promise associated with this deferred object.
  67871. */
  67872. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67873. /**
  67874. * The reject method of the promise associated with this deferred object.
  67875. */
  67876. get reject(): (reason?: any) => void;
  67877. /**
  67878. * Constructor for this deferred object.
  67879. */
  67880. constructor();
  67881. }
  67882. }
  67883. declare module BABYLON {
  67884. /**
  67885. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67886. */
  67887. export class MeshExploder {
  67888. private _centerMesh;
  67889. private _meshes;
  67890. private _meshesOrigins;
  67891. private _toCenterVectors;
  67892. private _scaledDirection;
  67893. private _newPosition;
  67894. private _centerPosition;
  67895. /**
  67896. * Explodes meshes from a center mesh.
  67897. * @param meshes The meshes to explode.
  67898. * @param centerMesh The mesh to be center of explosion.
  67899. */
  67900. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67901. private _setCenterMesh;
  67902. /**
  67903. * Get class name
  67904. * @returns "MeshExploder"
  67905. */
  67906. getClassName(): string;
  67907. /**
  67908. * "Exploded meshes"
  67909. * @returns Array of meshes with the centerMesh at index 0.
  67910. */
  67911. getMeshes(): Array<Mesh>;
  67912. /**
  67913. * Explodes meshes giving a specific direction
  67914. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67915. */
  67916. explode(direction?: number): void;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /**
  67921. * Class used to help managing file picking and drag'n'drop
  67922. */
  67923. export class FilesInput {
  67924. /**
  67925. * List of files ready to be loaded
  67926. */
  67927. static get FilesToLoad(): {
  67928. [key: string]: File;
  67929. };
  67930. /**
  67931. * Callback called when a file is processed
  67932. */
  67933. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67934. private _engine;
  67935. private _currentScene;
  67936. private _sceneLoadedCallback;
  67937. private _progressCallback;
  67938. private _additionalRenderLoopLogicCallback;
  67939. private _textureLoadingCallback;
  67940. private _startingProcessingFilesCallback;
  67941. private _onReloadCallback;
  67942. private _errorCallback;
  67943. private _elementToMonitor;
  67944. private _sceneFileToLoad;
  67945. private _filesToLoad;
  67946. /**
  67947. * Creates a new FilesInput
  67948. * @param engine defines the rendering engine
  67949. * @param scene defines the hosting scene
  67950. * @param sceneLoadedCallback callback called when scene is loaded
  67951. * @param progressCallback callback called to track progress
  67952. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67953. * @param textureLoadingCallback callback called when a texture is loading
  67954. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67955. * @param onReloadCallback callback called when a reload is requested
  67956. * @param errorCallback callback call if an error occurs
  67957. */
  67958. 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);
  67959. private _dragEnterHandler;
  67960. private _dragOverHandler;
  67961. private _dropHandler;
  67962. /**
  67963. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67964. * @param elementToMonitor defines the DOM element to track
  67965. */
  67966. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67967. /**
  67968. * Release all associated resources
  67969. */
  67970. dispose(): void;
  67971. private renderFunction;
  67972. private drag;
  67973. private drop;
  67974. private _traverseFolder;
  67975. private _processFiles;
  67976. /**
  67977. * Load files from a drop event
  67978. * @param event defines the drop event to use as source
  67979. */
  67980. loadFiles(event: any): void;
  67981. private _processReload;
  67982. /**
  67983. * Reload the current scene from the loaded files
  67984. */
  67985. reload(): void;
  67986. }
  67987. }
  67988. declare module BABYLON {
  67989. /**
  67990. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67991. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67992. */
  67993. export class SceneOptimization {
  67994. /**
  67995. * Defines the priority of this optimization (0 by default which means first in the list)
  67996. */
  67997. priority: number;
  67998. /**
  67999. * Gets a string describing the action executed by the current optimization
  68000. * @returns description string
  68001. */
  68002. getDescription(): string;
  68003. /**
  68004. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68005. * @param scene defines the current scene where to apply this optimization
  68006. * @param optimizer defines the current optimizer
  68007. * @returns true if everything that can be done was applied
  68008. */
  68009. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68010. /**
  68011. * Creates the SceneOptimization object
  68012. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68013. * @param desc defines the description associated with the optimization
  68014. */
  68015. constructor(
  68016. /**
  68017. * Defines the priority of this optimization (0 by default which means first in the list)
  68018. */
  68019. priority?: number);
  68020. }
  68021. /**
  68022. * Defines an optimization used to reduce the size of render target textures
  68023. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68024. */
  68025. export class TextureOptimization extends SceneOptimization {
  68026. /**
  68027. * Defines the priority of this optimization (0 by default which means first in the list)
  68028. */
  68029. priority: number;
  68030. /**
  68031. * 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
  68032. */
  68033. maximumSize: number;
  68034. /**
  68035. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68036. */
  68037. step: number;
  68038. /**
  68039. * Gets a string describing the action executed by the current optimization
  68040. * @returns description string
  68041. */
  68042. getDescription(): string;
  68043. /**
  68044. * Creates the TextureOptimization object
  68045. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68046. * @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
  68047. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68048. */
  68049. constructor(
  68050. /**
  68051. * Defines the priority of this optimization (0 by default which means first in the list)
  68052. */
  68053. priority?: number,
  68054. /**
  68055. * 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
  68056. */
  68057. maximumSize?: number,
  68058. /**
  68059. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68060. */
  68061. step?: number);
  68062. /**
  68063. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68064. * @param scene defines the current scene where to apply this optimization
  68065. * @param optimizer defines the current optimizer
  68066. * @returns true if everything that can be done was applied
  68067. */
  68068. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68069. }
  68070. /**
  68071. * Defines an optimization used to increase or decrease the rendering resolution
  68072. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68073. */
  68074. export class HardwareScalingOptimization extends SceneOptimization {
  68075. /**
  68076. * Defines the priority of this optimization (0 by default which means first in the list)
  68077. */
  68078. priority: number;
  68079. /**
  68080. * Defines the maximum scale to use (2 by default)
  68081. */
  68082. maximumScale: number;
  68083. /**
  68084. * Defines the step to use between two passes (0.5 by default)
  68085. */
  68086. step: number;
  68087. private _currentScale;
  68088. private _directionOffset;
  68089. /**
  68090. * Gets a string describing the action executed by the current optimization
  68091. * @return description string
  68092. */
  68093. getDescription(): string;
  68094. /**
  68095. * Creates the HardwareScalingOptimization object
  68096. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68097. * @param maximumScale defines the maximum scale to use (2 by default)
  68098. * @param step defines the step to use between two passes (0.5 by default)
  68099. */
  68100. constructor(
  68101. /**
  68102. * Defines the priority of this optimization (0 by default which means first in the list)
  68103. */
  68104. priority?: number,
  68105. /**
  68106. * Defines the maximum scale to use (2 by default)
  68107. */
  68108. maximumScale?: number,
  68109. /**
  68110. * Defines the step to use between two passes (0.5 by default)
  68111. */
  68112. step?: number);
  68113. /**
  68114. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68115. * @param scene defines the current scene where to apply this optimization
  68116. * @param optimizer defines the current optimizer
  68117. * @returns true if everything that can be done was applied
  68118. */
  68119. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68120. }
  68121. /**
  68122. * Defines an optimization used to remove shadows
  68123. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68124. */
  68125. export class ShadowsOptimization extends SceneOptimization {
  68126. /**
  68127. * Gets a string describing the action executed by the current optimization
  68128. * @return description string
  68129. */
  68130. getDescription(): string;
  68131. /**
  68132. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68133. * @param scene defines the current scene where to apply this optimization
  68134. * @param optimizer defines the current optimizer
  68135. * @returns true if everything that can be done was applied
  68136. */
  68137. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68138. }
  68139. /**
  68140. * Defines an optimization used to turn post-processes off
  68141. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68142. */
  68143. export class PostProcessesOptimization extends SceneOptimization {
  68144. /**
  68145. * Gets a string describing the action executed by the current optimization
  68146. * @return description string
  68147. */
  68148. getDescription(): string;
  68149. /**
  68150. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68151. * @param scene defines the current scene where to apply this optimization
  68152. * @param optimizer defines the current optimizer
  68153. * @returns true if everything that can be done was applied
  68154. */
  68155. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68156. }
  68157. /**
  68158. * Defines an optimization used to turn lens flares off
  68159. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68160. */
  68161. export class LensFlaresOptimization extends SceneOptimization {
  68162. /**
  68163. * Gets a string describing the action executed by the current optimization
  68164. * @return description string
  68165. */
  68166. getDescription(): string;
  68167. /**
  68168. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68169. * @param scene defines the current scene where to apply this optimization
  68170. * @param optimizer defines the current optimizer
  68171. * @returns true if everything that can be done was applied
  68172. */
  68173. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68174. }
  68175. /**
  68176. * Defines an optimization based on user defined callback.
  68177. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68178. */
  68179. export class CustomOptimization extends SceneOptimization {
  68180. /**
  68181. * Callback called to apply the custom optimization.
  68182. */
  68183. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68184. /**
  68185. * Callback called to get custom description
  68186. */
  68187. onGetDescription: () => string;
  68188. /**
  68189. * Gets a string describing the action executed by the current optimization
  68190. * @returns description string
  68191. */
  68192. getDescription(): string;
  68193. /**
  68194. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68195. * @param scene defines the current scene where to apply this optimization
  68196. * @param optimizer defines the current optimizer
  68197. * @returns true if everything that can be done was applied
  68198. */
  68199. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68200. }
  68201. /**
  68202. * Defines an optimization used to turn particles off
  68203. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68204. */
  68205. export class ParticlesOptimization extends SceneOptimization {
  68206. /**
  68207. * Gets a string describing the action executed by the current optimization
  68208. * @return description string
  68209. */
  68210. getDescription(): string;
  68211. /**
  68212. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68213. * @param scene defines the current scene where to apply this optimization
  68214. * @param optimizer defines the current optimizer
  68215. * @returns true if everything that can be done was applied
  68216. */
  68217. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68218. }
  68219. /**
  68220. * Defines an optimization used to turn render targets off
  68221. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68222. */
  68223. export class RenderTargetsOptimization extends SceneOptimization {
  68224. /**
  68225. * Gets a string describing the action executed by the current optimization
  68226. * @return description string
  68227. */
  68228. getDescription(): string;
  68229. /**
  68230. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68231. * @param scene defines the current scene where to apply this optimization
  68232. * @param optimizer defines the current optimizer
  68233. * @returns true if everything that can be done was applied
  68234. */
  68235. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68236. }
  68237. /**
  68238. * Defines an optimization used to merge meshes with compatible materials
  68239. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68240. */
  68241. export class MergeMeshesOptimization extends SceneOptimization {
  68242. private static _UpdateSelectionTree;
  68243. /**
  68244. * Gets or sets a boolean which defines if optimization octree has to be updated
  68245. */
  68246. static get UpdateSelectionTree(): boolean;
  68247. /**
  68248. * Gets or sets a boolean which defines if optimization octree has to be updated
  68249. */
  68250. static set UpdateSelectionTree(value: boolean);
  68251. /**
  68252. * Gets a string describing the action executed by the current optimization
  68253. * @return description string
  68254. */
  68255. getDescription(): string;
  68256. private _canBeMerged;
  68257. /**
  68258. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68259. * @param scene defines the current scene where to apply this optimization
  68260. * @param optimizer defines the current optimizer
  68261. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68262. * @returns true if everything that can be done was applied
  68263. */
  68264. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68265. }
  68266. /**
  68267. * Defines a list of options used by SceneOptimizer
  68268. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68269. */
  68270. export class SceneOptimizerOptions {
  68271. /**
  68272. * Defines the target frame rate to reach (60 by default)
  68273. */
  68274. targetFrameRate: number;
  68275. /**
  68276. * Defines the interval between two checkes (2000ms by default)
  68277. */
  68278. trackerDuration: number;
  68279. /**
  68280. * Gets the list of optimizations to apply
  68281. */
  68282. optimizations: SceneOptimization[];
  68283. /**
  68284. * Creates a new list of options used by SceneOptimizer
  68285. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68286. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68287. */
  68288. constructor(
  68289. /**
  68290. * Defines the target frame rate to reach (60 by default)
  68291. */
  68292. targetFrameRate?: number,
  68293. /**
  68294. * Defines the interval between two checkes (2000ms by default)
  68295. */
  68296. trackerDuration?: number);
  68297. /**
  68298. * Add a new optimization
  68299. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68300. * @returns the current SceneOptimizerOptions
  68301. */
  68302. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68303. /**
  68304. * Add a new custom optimization
  68305. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68306. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68307. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68308. * @returns the current SceneOptimizerOptions
  68309. */
  68310. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68311. /**
  68312. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68313. * @param targetFrameRate defines the target frame rate (60 by default)
  68314. * @returns a SceneOptimizerOptions object
  68315. */
  68316. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68317. /**
  68318. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68319. * @param targetFrameRate defines the target frame rate (60 by default)
  68320. * @returns a SceneOptimizerOptions object
  68321. */
  68322. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68323. /**
  68324. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68325. * @param targetFrameRate defines the target frame rate (60 by default)
  68326. * @returns a SceneOptimizerOptions object
  68327. */
  68328. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68329. }
  68330. /**
  68331. * Class used to run optimizations in order to reach a target frame rate
  68332. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68333. */
  68334. export class SceneOptimizer implements IDisposable {
  68335. private _isRunning;
  68336. private _options;
  68337. private _scene;
  68338. private _currentPriorityLevel;
  68339. private _targetFrameRate;
  68340. private _trackerDuration;
  68341. private _currentFrameRate;
  68342. private _sceneDisposeObserver;
  68343. private _improvementMode;
  68344. /**
  68345. * Defines an observable called when the optimizer reaches the target frame rate
  68346. */
  68347. onSuccessObservable: Observable<SceneOptimizer>;
  68348. /**
  68349. * Defines an observable called when the optimizer enables an optimization
  68350. */
  68351. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68352. /**
  68353. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68354. */
  68355. onFailureObservable: Observable<SceneOptimizer>;
  68356. /**
  68357. * Gets a boolean indicating if the optimizer is in improvement mode
  68358. */
  68359. get isInImprovementMode(): boolean;
  68360. /**
  68361. * Gets the current priority level (0 at start)
  68362. */
  68363. get currentPriorityLevel(): number;
  68364. /**
  68365. * Gets the current frame rate checked by the SceneOptimizer
  68366. */
  68367. get currentFrameRate(): number;
  68368. /**
  68369. * Gets or sets the current target frame rate (60 by default)
  68370. */
  68371. get targetFrameRate(): number;
  68372. /**
  68373. * Gets or sets the current target frame rate (60 by default)
  68374. */
  68375. set targetFrameRate(value: number);
  68376. /**
  68377. * Gets or sets the current interval between two checks (every 2000ms by default)
  68378. */
  68379. get trackerDuration(): number;
  68380. /**
  68381. * Gets or sets the current interval between two checks (every 2000ms by default)
  68382. */
  68383. set trackerDuration(value: number);
  68384. /**
  68385. * Gets the list of active optimizations
  68386. */
  68387. get optimizations(): SceneOptimization[];
  68388. /**
  68389. * Creates a new SceneOptimizer
  68390. * @param scene defines the scene to work on
  68391. * @param options defines the options to use with the SceneOptimizer
  68392. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68393. * @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)
  68394. */
  68395. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68396. /**
  68397. * Stops the current optimizer
  68398. */
  68399. stop(): void;
  68400. /**
  68401. * Reset the optimizer to initial step (current priority level = 0)
  68402. */
  68403. reset(): void;
  68404. /**
  68405. * Start the optimizer. By default it will try to reach a specific framerate
  68406. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68407. */
  68408. start(): void;
  68409. private _checkCurrentState;
  68410. /**
  68411. * Release all resources
  68412. */
  68413. dispose(): void;
  68414. /**
  68415. * Helper function to create a SceneOptimizer with one single line of code
  68416. * @param scene defines the scene to work on
  68417. * @param options defines the options to use with the SceneOptimizer
  68418. * @param onSuccess defines a callback to call on success
  68419. * @param onFailure defines a callback to call on failure
  68420. * @returns the new SceneOptimizer object
  68421. */
  68422. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68423. }
  68424. }
  68425. declare module BABYLON {
  68426. /**
  68427. * Class used to serialize a scene into a string
  68428. */
  68429. export class SceneSerializer {
  68430. /**
  68431. * Clear cache used by a previous serialization
  68432. */
  68433. static ClearCache(): void;
  68434. /**
  68435. * Serialize a scene into a JSON compatible object
  68436. * @param scene defines the scene to serialize
  68437. * @returns a JSON compatible object
  68438. */
  68439. static Serialize(scene: Scene): any;
  68440. /**
  68441. * Serialize a mesh into a JSON compatible object
  68442. * @param toSerialize defines the mesh to serialize
  68443. * @param withParents defines if parents must be serialized as well
  68444. * @param withChildren defines if children must be serialized as well
  68445. * @returns a JSON compatible object
  68446. */
  68447. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68448. }
  68449. }
  68450. declare module BABYLON {
  68451. /**
  68452. * Class used to host texture specific utilities
  68453. */
  68454. export class TextureTools {
  68455. /**
  68456. * Uses the GPU to create a copy texture rescaled at a given size
  68457. * @param texture Texture to copy from
  68458. * @param width defines the desired width
  68459. * @param height defines the desired height
  68460. * @param useBilinearMode defines if bilinear mode has to be used
  68461. * @return the generated texture
  68462. */
  68463. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * This represents the different options available for the video capture.
  68469. */
  68470. export interface VideoRecorderOptions {
  68471. /** Defines the mime type of the video. */
  68472. mimeType: string;
  68473. /** Defines the FPS the video should be recorded at. */
  68474. fps: number;
  68475. /** Defines the chunk size for the recording data. */
  68476. recordChunckSize: number;
  68477. /** The audio tracks to attach to the recording. */
  68478. audioTracks?: MediaStreamTrack[];
  68479. }
  68480. /**
  68481. * This can help with recording videos from BabylonJS.
  68482. * This is based on the available WebRTC functionalities of the browser.
  68483. *
  68484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68485. */
  68486. export class VideoRecorder {
  68487. private static readonly _defaultOptions;
  68488. /**
  68489. * Returns whether or not the VideoRecorder is available in your browser.
  68490. * @param engine Defines the Babylon Engine.
  68491. * @returns true if supported otherwise false.
  68492. */
  68493. static IsSupported(engine: Engine): boolean;
  68494. private readonly _options;
  68495. private _canvas;
  68496. private _mediaRecorder;
  68497. private _recordedChunks;
  68498. private _fileName;
  68499. private _resolve;
  68500. private _reject;
  68501. /**
  68502. * True when a recording is already in progress.
  68503. */
  68504. get isRecording(): boolean;
  68505. /**
  68506. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68507. * @param engine Defines the BabylonJS Engine you wish to record.
  68508. * @param options Defines options that can be used to customize the capture.
  68509. */
  68510. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68511. /**
  68512. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68513. */
  68514. stopRecording(): void;
  68515. /**
  68516. * Starts recording the canvas for a max duration specified in parameters.
  68517. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68518. * If null no automatic download will start and you can rely on the promise to get the data back.
  68519. * @param maxDuration Defines the maximum recording time in seconds.
  68520. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68521. * @return A promise callback at the end of the recording with the video data in Blob.
  68522. */
  68523. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68524. /**
  68525. * Releases internal resources used during the recording.
  68526. */
  68527. dispose(): void;
  68528. private _handleDataAvailable;
  68529. private _handleError;
  68530. private _handleStop;
  68531. }
  68532. }
  68533. declare module BABYLON {
  68534. /**
  68535. * Class containing a set of static utilities functions for screenshots
  68536. */
  68537. export class ScreenshotTools {
  68538. /**
  68539. * Captures a screenshot of the current rendering
  68540. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68541. * @param engine defines the rendering engine
  68542. * @param camera defines the source camera
  68543. * @param size This parameter can be set to a single number or to an object with the
  68544. * following (optional) properties: precision, width, height. If a single number is passed,
  68545. * it will be used for both width and height. If an object is passed, the screenshot size
  68546. * will be derived from the parameters. The precision property is a multiplier allowing
  68547. * rendering at a higher or lower resolution
  68548. * @param successCallback defines the callback receives a single parameter which contains the
  68549. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68550. * src parameter of an <img> to display it
  68551. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68552. * Check your browser for supported MIME types
  68553. */
  68554. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68555. /**
  68556. * Captures a screenshot of the current rendering
  68557. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68558. * @param engine defines the rendering engine
  68559. * @param camera defines the source camera
  68560. * @param size This parameter can be set to a single number or to an object with the
  68561. * following (optional) properties: precision, width, height. If a single number is passed,
  68562. * it will be used for both width and height. If an object is passed, the screenshot size
  68563. * will be derived from the parameters. The precision property is a multiplier allowing
  68564. * rendering at a higher or lower resolution
  68565. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68566. * Check your browser for supported MIME types
  68567. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68568. * to the src parameter of an <img> to display it
  68569. */
  68570. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68571. /**
  68572. * Generates an image screenshot from the specified camera.
  68573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68574. * @param engine The engine to use for rendering
  68575. * @param camera The camera to use for rendering
  68576. * @param size This parameter can be set to a single number or to an object with the
  68577. * following (optional) properties: precision, width, height. If a single number is passed,
  68578. * it will be used for both width and height. If an object is passed, the screenshot size
  68579. * will be derived from the parameters. The precision property is a multiplier allowing
  68580. * rendering at a higher or lower resolution
  68581. * @param successCallback The callback receives a single parameter which contains the
  68582. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68583. * src parameter of an <img> to display it
  68584. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68585. * Check your browser for supported MIME types
  68586. * @param samples Texture samples (default: 1)
  68587. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68588. * @param fileName A name for for the downloaded file.
  68589. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68590. */
  68591. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  68592. /**
  68593. * Generates an image screenshot from the specified camera.
  68594. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68595. * @param engine The engine to use for rendering
  68596. * @param camera The camera to use for rendering
  68597. * @param size This parameter can be set to a single number or to an object with the
  68598. * following (optional) properties: precision, width, height. If a single number is passed,
  68599. * it will be used for both width and height. If an object is passed, the screenshot size
  68600. * will be derived from the parameters. The precision property is a multiplier allowing
  68601. * rendering at a higher or lower resolution
  68602. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68603. * Check your browser for supported MIME types
  68604. * @param samples Texture samples (default: 1)
  68605. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68606. * @param fileName A name for for the downloaded file.
  68607. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  68608. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68609. * to the src parameter of an <img> to display it
  68610. */
  68611. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  68612. /**
  68613. * Gets height and width for screenshot size
  68614. * @private
  68615. */
  68616. private static _getScreenshotSize;
  68617. }
  68618. }
  68619. declare module BABYLON {
  68620. /**
  68621. * Interface for a data buffer
  68622. */
  68623. export interface IDataBuffer {
  68624. /**
  68625. * Reads bytes from the data buffer.
  68626. * @param byteOffset The byte offset to read
  68627. * @param byteLength The byte length to read
  68628. * @returns A promise that resolves when the bytes are read
  68629. */
  68630. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68631. /**
  68632. * The byte length of the buffer.
  68633. */
  68634. readonly byteLength: number;
  68635. }
  68636. /**
  68637. * Utility class for reading from a data buffer
  68638. */
  68639. export class DataReader {
  68640. /**
  68641. * The data buffer associated with this data reader.
  68642. */
  68643. readonly buffer: IDataBuffer;
  68644. /**
  68645. * The current byte offset from the beginning of the data buffer.
  68646. */
  68647. byteOffset: number;
  68648. private _dataView;
  68649. private _dataByteOffset;
  68650. /**
  68651. * Constructor
  68652. * @param buffer The buffer to read
  68653. */
  68654. constructor(buffer: IDataBuffer);
  68655. /**
  68656. * Loads the given byte length.
  68657. * @param byteLength The byte length to load
  68658. * @returns A promise that resolves when the load is complete
  68659. */
  68660. loadAsync(byteLength: number): Promise<void>;
  68661. /**
  68662. * Read a unsigned 32-bit integer from the currently loaded data range.
  68663. * @returns The 32-bit integer read
  68664. */
  68665. readUint32(): number;
  68666. /**
  68667. * Read a byte array from the currently loaded data range.
  68668. * @param byteLength The byte length to read
  68669. * @returns The byte array read
  68670. */
  68671. readUint8Array(byteLength: number): Uint8Array;
  68672. /**
  68673. * Read a string from the currently loaded data range.
  68674. * @param byteLength The byte length to read
  68675. * @returns The string read
  68676. */
  68677. readString(byteLength: number): string;
  68678. /**
  68679. * Skips the given byte length the currently loaded data range.
  68680. * @param byteLength The byte length to skip
  68681. */
  68682. skipBytes(byteLength: number): void;
  68683. }
  68684. }
  68685. declare module BABYLON {
  68686. /**
  68687. * Options used for hit testing
  68688. */
  68689. export interface IWebXRHitTestOptions {
  68690. /**
  68691. * Only test when user interacted with the scene. Default - hit test every frame
  68692. */
  68693. testOnPointerDownOnly?: boolean;
  68694. /**
  68695. * The node to use to transform the local results to world coordinates
  68696. */
  68697. worldParentNode?: TransformNode;
  68698. }
  68699. /**
  68700. * Interface defining the babylon result of raycasting/hit-test
  68701. */
  68702. export interface IWebXRHitResult {
  68703. /**
  68704. * The native hit test result
  68705. */
  68706. xrHitResult: XRHitResult;
  68707. /**
  68708. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68709. */
  68710. transformationMatrix: Matrix;
  68711. }
  68712. /**
  68713. * The currently-working hit-test module.
  68714. * Hit test (or raycasting) is used to interact with the real world.
  68715. * For further information read here - https://github.com/immersive-web/hit-test
  68716. */
  68717. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68718. /**
  68719. * options to use when constructing this feature
  68720. */
  68721. readonly options: IWebXRHitTestOptions;
  68722. /**
  68723. * The module's name
  68724. */
  68725. static readonly Name: string;
  68726. /**
  68727. * The (Babylon) version of this module.
  68728. * This is an integer representing the implementation version.
  68729. * This number does not correspond to the webxr specs version
  68730. */
  68731. static readonly Version: number;
  68732. /**
  68733. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68734. * @param event the (select) event to use to select with
  68735. * @param referenceSpace the reference space to use for this hit test
  68736. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68737. */
  68738. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68739. /**
  68740. * execute a hit test with an XR Ray
  68741. *
  68742. * @param xrSession a native xrSession that will execute this hit test
  68743. * @param xrRay the ray (position and direction) to use for raycasting
  68744. * @param referenceSpace native XR reference space to use for the hit-test
  68745. * @param filter filter function that will filter the results
  68746. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68747. */
  68748. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68749. /**
  68750. * Triggered when new babylon (transformed) hit test results are available
  68751. */
  68752. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68753. private _onSelectEnabled;
  68754. /**
  68755. * Creates a new instance of the (legacy version) hit test feature
  68756. * @param _xrSessionManager an instance of WebXRSessionManager
  68757. * @param options options to use when constructing this feature
  68758. */
  68759. constructor(_xrSessionManager: WebXRSessionManager,
  68760. /**
  68761. * options to use when constructing this feature
  68762. */
  68763. options?: IWebXRHitTestOptions);
  68764. /**
  68765. * Populated with the last native XR Hit Results
  68766. */
  68767. lastNativeXRHitResults: XRHitResult[];
  68768. /**
  68769. * attach this feature
  68770. * Will usually be called by the features manager
  68771. *
  68772. * @returns true if successful.
  68773. */
  68774. attach(): boolean;
  68775. /**
  68776. * detach this feature.
  68777. * Will usually be called by the features manager
  68778. *
  68779. * @returns true if successful.
  68780. */
  68781. detach(): boolean;
  68782. private _onHitTestResults;
  68783. private _origin;
  68784. private _direction;
  68785. private _mat;
  68786. protected _onXRFrame(frame: XRFrame): void;
  68787. private _onSelect;
  68788. /**
  68789. * Dispose this feature and all of the resources attached
  68790. */
  68791. dispose(): void;
  68792. }
  68793. }
  68794. declare module BABYLON {
  68795. /**
  68796. * Options used in the plane detector module
  68797. */
  68798. export interface IWebXRPlaneDetectorOptions {
  68799. /**
  68800. * The node to use to transform the local results to world coordinates
  68801. */
  68802. worldParentNode?: TransformNode;
  68803. }
  68804. /**
  68805. * A babylon interface for a webxr plane.
  68806. * A Plane is actually a polygon, built from N points in space
  68807. *
  68808. * Supported in chrome 79, not supported in canary 81 ATM
  68809. */
  68810. export interface IWebXRPlane {
  68811. /**
  68812. * a babylon-assigned ID for this polygon
  68813. */
  68814. id: number;
  68815. /**
  68816. * the native xr-plane object
  68817. */
  68818. xrPlane: XRPlane;
  68819. /**
  68820. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68821. */
  68822. polygonDefinition: Array<Vector3>;
  68823. /**
  68824. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68825. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68826. */
  68827. transformationMatrix: Matrix;
  68828. }
  68829. /**
  68830. * The plane detector is used to detect planes in the real world when in AR
  68831. * For more information see https://github.com/immersive-web/real-world-geometry/
  68832. */
  68833. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68834. private _options;
  68835. /**
  68836. * The module's name
  68837. */
  68838. static readonly Name: string;
  68839. /**
  68840. * The (Babylon) version of this module.
  68841. * This is an integer representing the implementation version.
  68842. * This number does not correspond to the webxr specs version
  68843. */
  68844. static readonly Version: number;
  68845. /**
  68846. * Observers registered here will be executed when a new plane was added to the session
  68847. */
  68848. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68849. /**
  68850. * Observers registered here will be executed when a plane is no longer detected in the session
  68851. */
  68852. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68853. /**
  68854. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68855. * This can execute N times every frame
  68856. */
  68857. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68858. private _enabled;
  68859. private _detectedPlanes;
  68860. private _lastFrameDetected;
  68861. /**
  68862. * construct a new Plane Detector
  68863. * @param _xrSessionManager an instance of xr Session manager
  68864. * @param _options configuration to use when constructing this feature
  68865. */
  68866. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68867. private _init;
  68868. protected _onXRFrame(frame: XRFrame): void;
  68869. /**
  68870. * Dispose this feature and all of the resources attached
  68871. */
  68872. dispose(): void;
  68873. private _updatePlaneWithXRPlane;
  68874. /**
  68875. * avoiding using Array.find for global support.
  68876. * @param xrPlane the plane to find in the array
  68877. */
  68878. private findIndexInPlaneArray;
  68879. }
  68880. }
  68881. declare module BABYLON {
  68882. /**
  68883. * Configuration options of the anchor system
  68884. */
  68885. export interface IWebXRAnchorSystemOptions {
  68886. /**
  68887. * a node that will be used to convert local to world coordinates
  68888. */
  68889. worldParentNode?: TransformNode;
  68890. /**
  68891. * should the anchor system use plane detection.
  68892. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68893. */
  68894. usePlaneDetection?: boolean;
  68895. /**
  68896. * Should a new anchor be added every time a select event is triggered
  68897. */
  68898. addAnchorOnSelect?: boolean;
  68899. }
  68900. /**
  68901. * A babylon container for an XR Anchor
  68902. */
  68903. export interface IWebXRAnchor {
  68904. /**
  68905. * A babylon-assigned ID for this anchor
  68906. */
  68907. id: number;
  68908. /**
  68909. * The native anchor object
  68910. */
  68911. xrAnchor: XRAnchor;
  68912. /**
  68913. * Transformation matrix to apply to an object attached to this anchor
  68914. */
  68915. transformationMatrix: Matrix;
  68916. }
  68917. /**
  68918. * An implementation of the anchor system of WebXR.
  68919. * Note that the current documented implementation is not available in any browser. Future implementations
  68920. * will use the frame to create an anchor and not the session or a detected plane
  68921. * For further information see https://github.com/immersive-web/anchors/
  68922. */
  68923. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68924. private _options;
  68925. /**
  68926. * The module's name
  68927. */
  68928. static readonly Name: string;
  68929. /**
  68930. * The (Babylon) version of this module.
  68931. * This is an integer representing the implementation version.
  68932. * This number does not correspond to the webxr specs version
  68933. */
  68934. static readonly Version: number;
  68935. /**
  68936. * Observers registered here will be executed when a new anchor was added to the session
  68937. */
  68938. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68939. /**
  68940. * Observers registered here will be executed when an existing anchor updates
  68941. * This can execute N times every frame
  68942. */
  68943. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68944. /**
  68945. * Observers registered here will be executed when an anchor was removed from the session
  68946. */
  68947. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68948. private _planeDetector;
  68949. private _hitTestModule;
  68950. private _enabled;
  68951. private _trackedAnchors;
  68952. private _lastFrameDetected;
  68953. /**
  68954. * constructs a new anchor system
  68955. * @param _xrSessionManager an instance of WebXRSessionManager
  68956. * @param _options configuration object for this feature
  68957. */
  68958. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68959. /**
  68960. * set the plane detector to use in order to create anchors from frames
  68961. * @param planeDetector the plane-detector module to use
  68962. * @param enable enable plane-anchors. default is true
  68963. */
  68964. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68965. /**
  68966. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68967. * @param hitTestModule the hit-test module to use.
  68968. */
  68969. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68970. /**
  68971. * attach this feature
  68972. * Will usually be called by the features manager
  68973. *
  68974. * @returns true if successful.
  68975. */
  68976. attach(): boolean;
  68977. /**
  68978. * detach this feature.
  68979. * Will usually be called by the features manager
  68980. *
  68981. * @returns true if successful.
  68982. */
  68983. detach(): boolean;
  68984. /**
  68985. * Dispose this feature and all of the resources attached
  68986. */
  68987. dispose(): void;
  68988. protected _onXRFrame(frame: XRFrame): void;
  68989. private _onSelect;
  68990. /**
  68991. * Add anchor at a specific XR point.
  68992. *
  68993. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68994. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68995. * @returns a promise the fulfills when the anchor was created
  68996. */
  68997. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68998. private _updateAnchorWithXRFrame;
  68999. /**
  69000. * avoiding using Array.find for global support.
  69001. * @param xrAnchor the plane to find in the array
  69002. */
  69003. private _findIndexInAnchorArray;
  69004. }
  69005. }
  69006. declare module BABYLON {
  69007. /**
  69008. * Options interface for the background remover plugin
  69009. */
  69010. export interface IWebXRBackgroundRemoverOptions {
  69011. /**
  69012. * don't disable the environment helper
  69013. */
  69014. ignoreEnvironmentHelper?: boolean;
  69015. /**
  69016. * flags to configure the removal of the environment helper.
  69017. * If not set, the entire background will be removed. If set, flags should be set as well.
  69018. */
  69019. environmentHelperRemovalFlags?: {
  69020. /**
  69021. * Should the skybox be removed (default false)
  69022. */
  69023. skyBox?: boolean;
  69024. /**
  69025. * Should the ground be removed (default false)
  69026. */
  69027. ground?: boolean;
  69028. };
  69029. /**
  69030. * Further background meshes to disable when entering AR
  69031. */
  69032. backgroundMeshes?: AbstractMesh[];
  69033. }
  69034. /**
  69035. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  69036. */
  69037. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  69038. /**
  69039. * read-only options to be used in this module
  69040. */
  69041. readonly options: IWebXRBackgroundRemoverOptions;
  69042. /**
  69043. * The module's name
  69044. */
  69045. static readonly Name: string;
  69046. /**
  69047. * The (Babylon) version of this module.
  69048. * This is an integer representing the implementation version.
  69049. * This number does not correspond to the webxr specs version
  69050. */
  69051. static readonly Version: number;
  69052. /**
  69053. * registered observers will be triggered when the background state changes
  69054. */
  69055. onBackgroundStateChangedObservable: Observable<boolean>;
  69056. /**
  69057. * constructs a new background remover module
  69058. * @param _xrSessionManager the session manager for this module
  69059. * @param options read-only options to be used in this module
  69060. */
  69061. constructor(_xrSessionManager: WebXRSessionManager,
  69062. /**
  69063. * read-only options to be used in this module
  69064. */
  69065. options?: IWebXRBackgroundRemoverOptions);
  69066. /**
  69067. * attach this feature
  69068. * Will usually be called by the features manager
  69069. *
  69070. * @returns true if successful.
  69071. */
  69072. attach(): boolean;
  69073. /**
  69074. * detach this feature.
  69075. * Will usually be called by the features manager
  69076. *
  69077. * @returns true if successful.
  69078. */
  69079. detach(): boolean;
  69080. private _setBackgroundState;
  69081. /**
  69082. * Dispose this feature and all of the resources attached
  69083. */
  69084. dispose(): void;
  69085. protected _onXRFrame(_xrFrame: XRFrame): void;
  69086. }
  69087. }
  69088. declare module BABYLON {
  69089. /**
  69090. * Options for the controller physics feature
  69091. */
  69092. export class IWebXRControllerPhysicsOptions {
  69093. /**
  69094. * the xr input to use with this pointer selection
  69095. */
  69096. xrInput: WebXRInput;
  69097. /**
  69098. * The physics properties of the future impostors
  69099. */
  69100. physicsProperties?: {
  69101. /**
  69102. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69103. * Note that this requires a physics engine that supports mesh impostors!
  69104. */
  69105. useControllerMesh?: boolean;
  69106. /**
  69107. * The type of impostor to create. Default is sphere
  69108. */
  69109. impostorType?: number;
  69110. /**
  69111. * the size of the impostor. Defaults to 10cm
  69112. */
  69113. impostorSize?: number | {
  69114. width: number;
  69115. height: number;
  69116. depth: number;
  69117. };
  69118. /**
  69119. * Friction definitions
  69120. */
  69121. friction?: number;
  69122. /**
  69123. * Restitution
  69124. */
  69125. restitution?: number;
  69126. };
  69127. /**
  69128. * Should the headset get its own impostor
  69129. */
  69130. enableHeadsetImpostor?: boolean;
  69131. /**
  69132. * Optional parameters for the headset impostor
  69133. */
  69134. headsetImpostorParams?: {
  69135. /**
  69136. * The type of impostor to create. Default is sphere
  69137. */
  69138. impostorType: number;
  69139. /**
  69140. * the size of the impostor. Defaults to 10cm
  69141. */
  69142. impostorSize?: number | {
  69143. width: number;
  69144. height: number;
  69145. depth: number;
  69146. };
  69147. /**
  69148. * Friction definitions
  69149. */
  69150. friction?: number;
  69151. /**
  69152. * Restitution
  69153. */
  69154. restitution?: number;
  69155. };
  69156. }
  69157. /**
  69158. * Add physics impostor to your webxr controllers,
  69159. * including naive calculation of their linear and angular velocity
  69160. */
  69161. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69162. private readonly _options;
  69163. /**
  69164. * The module's name
  69165. */
  69166. static readonly Name: string;
  69167. /**
  69168. * The (Babylon) version of this module.
  69169. * This is an integer representing the implementation version.
  69170. * This number does not correspond to the webxr specs version
  69171. */
  69172. static readonly Version: number;
  69173. private _lastTimestamp;
  69174. private _delta;
  69175. private _controllers;
  69176. private _headsetImpostor?;
  69177. private _headsetMesh?;
  69178. private _tmpVector;
  69179. private _tmpQuaternion;
  69180. /**
  69181. * Construct a new Controller Physics Feature
  69182. * @param _xrSessionManager the corresponding xr session manager
  69183. * @param _options options to create this feature with
  69184. */
  69185. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69186. /**
  69187. * Update the physics properties provided in the constructor
  69188. * @param newProperties the new properties object
  69189. */
  69190. setPhysicsProperties(newProperties: {
  69191. impostorType?: number;
  69192. impostorSize?: number | {
  69193. width: number;
  69194. height: number;
  69195. depth: number;
  69196. };
  69197. friction?: number;
  69198. restitution?: number;
  69199. }): void;
  69200. /**
  69201. * Get the physics impostor of a specific controller.
  69202. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  69203. * @param controller the controller or the controller id of which to get the impostor
  69204. * @returns the impostor or null
  69205. */
  69206. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  69207. /**
  69208. * Get the headset impostor, if enabled
  69209. * @returns the impostor
  69210. */
  69211. getHeadsetImpostor(): PhysicsImpostor | undefined;
  69212. /**
  69213. * attach this feature
  69214. * Will usually be called by the features manager
  69215. *
  69216. * @returns true if successful.
  69217. */
  69218. attach(): boolean;
  69219. /**
  69220. * detach this feature.
  69221. * Will usually be called by the features manager
  69222. *
  69223. * @returns true if successful.
  69224. */
  69225. detach(): boolean;
  69226. /**
  69227. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69228. * @param xrController the controller to add
  69229. */
  69230. addController(xrController: WebXRInputSource): void;
  69231. private _debugMode;
  69232. /**
  69233. * @hidden
  69234. * enable debugging - will show console outputs and the impostor mesh
  69235. */
  69236. _enablePhysicsDebug(): void;
  69237. private _attachController;
  69238. private _detachController;
  69239. protected _onXRFrame(_xrFrame: any): void;
  69240. }
  69241. }
  69242. declare module BABYLON {
  69243. /**
  69244. * The motion controller class for all microsoft mixed reality controllers
  69245. */
  69246. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69247. /**
  69248. * The base url used to load the left and right controller models
  69249. */
  69250. static MODEL_BASE_URL: string;
  69251. /**
  69252. * The name of the left controller model file
  69253. */
  69254. static MODEL_LEFT_FILENAME: string;
  69255. /**
  69256. * The name of the right controller model file
  69257. */
  69258. static MODEL_RIGHT_FILENAME: string;
  69259. profileId: string;
  69260. protected readonly _mapping: {
  69261. defaultButton: {
  69262. "valueNodeName": string;
  69263. "unpressedNodeName": string;
  69264. "pressedNodeName": string;
  69265. };
  69266. defaultAxis: {
  69267. "valueNodeName": string;
  69268. "minNodeName": string;
  69269. "maxNodeName": string;
  69270. };
  69271. buttons: {
  69272. "xr-standard-trigger": {
  69273. "rootNodeName": string;
  69274. "componentProperty": string;
  69275. "states": string[];
  69276. };
  69277. "xr-standard-squeeze": {
  69278. "rootNodeName": string;
  69279. "componentProperty": string;
  69280. "states": string[];
  69281. };
  69282. "xr-standard-touchpad": {
  69283. "rootNodeName": string;
  69284. "labelAnchorNodeName": string;
  69285. "touchPointNodeName": string;
  69286. };
  69287. "xr-standard-thumbstick": {
  69288. "rootNodeName": string;
  69289. "componentProperty": string;
  69290. "states": string[];
  69291. };
  69292. };
  69293. axes: {
  69294. "xr-standard-touchpad": {
  69295. "x-axis": {
  69296. "rootNodeName": string;
  69297. };
  69298. "y-axis": {
  69299. "rootNodeName": string;
  69300. };
  69301. };
  69302. "xr-standard-thumbstick": {
  69303. "x-axis": {
  69304. "rootNodeName": string;
  69305. };
  69306. "y-axis": {
  69307. "rootNodeName": string;
  69308. };
  69309. };
  69310. };
  69311. };
  69312. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69313. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69314. protected _getFilenameAndPath(): {
  69315. filename: string;
  69316. path: string;
  69317. };
  69318. protected _updateModel(): void;
  69319. protected _getModelLoadingConstraints(): boolean;
  69320. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69321. }
  69322. }
  69323. declare module BABYLON {
  69324. /**
  69325. * The motion controller class for oculus touch (quest, rift).
  69326. * This class supports legacy mapping as well the standard xr mapping
  69327. */
  69328. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69329. private _forceLegacyControllers;
  69330. /**
  69331. * The base url used to load the left and right controller models
  69332. */
  69333. static MODEL_BASE_URL: string;
  69334. /**
  69335. * The name of the left controller model file
  69336. */
  69337. static MODEL_LEFT_FILENAME: string;
  69338. /**
  69339. * The name of the right controller model file
  69340. */
  69341. static MODEL_RIGHT_FILENAME: string;
  69342. /**
  69343. * Base Url for the Quest controller model.
  69344. */
  69345. static QUEST_MODEL_BASE_URL: string;
  69346. profileId: string;
  69347. private _modelRootNode;
  69348. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69349. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69350. protected _getFilenameAndPath(): {
  69351. filename: string;
  69352. path: string;
  69353. };
  69354. /**
  69355. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69356. * between the touch and touch 2.
  69357. */
  69358. private _isQuest;
  69359. protected _updateModel(): void;
  69360. protected _getModelLoadingConstraints(): boolean;
  69361. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69362. }
  69363. }
  69364. declare module BABYLON {
  69365. /**
  69366. * The motion controller class for the standard HTC-Vive controllers
  69367. */
  69368. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69369. /**
  69370. * The base url used to load the left and right controller models
  69371. */
  69372. static MODEL_BASE_URL: string;
  69373. /**
  69374. * File name for the controller model.
  69375. */
  69376. static MODEL_FILENAME: string;
  69377. profileId: string;
  69378. private _modelRootNode;
  69379. /**
  69380. * Create a new Vive motion controller object
  69381. * @param scene the scene to use to create this controller
  69382. * @param gamepadObject the corresponding gamepad object
  69383. * @param handness the handness of the controller
  69384. */
  69385. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69386. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69387. protected _getFilenameAndPath(): {
  69388. filename: string;
  69389. path: string;
  69390. };
  69391. protected _updateModel(): void;
  69392. protected _getModelLoadingConstraints(): boolean;
  69393. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69394. }
  69395. }
  69396. declare module BABYLON {
  69397. /**
  69398. * A cursor which tracks a point on a path
  69399. */
  69400. export class PathCursor {
  69401. private path;
  69402. /**
  69403. * Stores path cursor callbacks for when an onchange event is triggered
  69404. */
  69405. private _onchange;
  69406. /**
  69407. * The value of the path cursor
  69408. */
  69409. value: number;
  69410. /**
  69411. * The animation array of the path cursor
  69412. */
  69413. animations: Animation[];
  69414. /**
  69415. * Initializes the path cursor
  69416. * @param path The path to track
  69417. */
  69418. constructor(path: Path2);
  69419. /**
  69420. * Gets the cursor point on the path
  69421. * @returns A point on the path cursor at the cursor location
  69422. */
  69423. getPoint(): Vector3;
  69424. /**
  69425. * Moves the cursor ahead by the step amount
  69426. * @param step The amount to move the cursor forward
  69427. * @returns This path cursor
  69428. */
  69429. moveAhead(step?: number): PathCursor;
  69430. /**
  69431. * Moves the cursor behind by the step amount
  69432. * @param step The amount to move the cursor back
  69433. * @returns This path cursor
  69434. */
  69435. moveBack(step?: number): PathCursor;
  69436. /**
  69437. * Moves the cursor by the step amount
  69438. * If the step amount is greater than one, an exception is thrown
  69439. * @param step The amount to move the cursor
  69440. * @returns This path cursor
  69441. */
  69442. move(step: number): PathCursor;
  69443. /**
  69444. * Ensures that the value is limited between zero and one
  69445. * @returns This path cursor
  69446. */
  69447. private ensureLimits;
  69448. /**
  69449. * Runs onchange callbacks on change (used by the animation engine)
  69450. * @returns This path cursor
  69451. */
  69452. private raiseOnChange;
  69453. /**
  69454. * Executes a function on change
  69455. * @param f A path cursor onchange callback
  69456. * @returns This path cursor
  69457. */
  69458. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69459. }
  69460. }
  69461. declare module BABYLON {
  69462. /** @hidden */
  69463. export var blurPixelShader: {
  69464. name: string;
  69465. shader: string;
  69466. };
  69467. }
  69468. declare module BABYLON {
  69469. /** @hidden */
  69470. export var pointCloudVertexDeclaration: {
  69471. name: string;
  69472. shader: string;
  69473. };
  69474. }
  69475. // Mixins
  69476. interface Window {
  69477. mozIndexedDB: IDBFactory;
  69478. webkitIndexedDB: IDBFactory;
  69479. msIndexedDB: IDBFactory;
  69480. webkitURL: typeof URL;
  69481. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69482. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69483. WebGLRenderingContext: WebGLRenderingContext;
  69484. MSGesture: MSGesture;
  69485. CANNON: any;
  69486. AudioContext: AudioContext;
  69487. webkitAudioContext: AudioContext;
  69488. PointerEvent: any;
  69489. Math: Math;
  69490. Uint8Array: Uint8ArrayConstructor;
  69491. Float32Array: Float32ArrayConstructor;
  69492. mozURL: typeof URL;
  69493. msURL: typeof URL;
  69494. VRFrameData: any; // WebVR, from specs 1.1
  69495. DracoDecoderModule: any;
  69496. setImmediate(handler: (...args: any[]) => void): number;
  69497. }
  69498. interface HTMLCanvasElement {
  69499. requestPointerLock(): void;
  69500. msRequestPointerLock?(): void;
  69501. mozRequestPointerLock?(): void;
  69502. webkitRequestPointerLock?(): void;
  69503. /** Track wether a record is in progress */
  69504. isRecording: boolean;
  69505. /** Capture Stream method defined by some browsers */
  69506. captureStream(fps?: number): MediaStream;
  69507. }
  69508. interface CanvasRenderingContext2D {
  69509. msImageSmoothingEnabled: boolean;
  69510. }
  69511. interface MouseEvent {
  69512. mozMovementX: number;
  69513. mozMovementY: number;
  69514. webkitMovementX: number;
  69515. webkitMovementY: number;
  69516. msMovementX: number;
  69517. msMovementY: number;
  69518. }
  69519. interface Navigator {
  69520. mozGetVRDevices: (any: any) => any;
  69521. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69522. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69523. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69524. webkitGetGamepads(): Gamepad[];
  69525. msGetGamepads(): Gamepad[];
  69526. webkitGamepads(): Gamepad[];
  69527. }
  69528. interface HTMLVideoElement {
  69529. mozSrcObject: any;
  69530. }
  69531. interface Math {
  69532. fround(x: number): number;
  69533. imul(a: number, b: number): number;
  69534. }
  69535. interface WebGLRenderingContext {
  69536. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69537. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69538. vertexAttribDivisor(index: number, divisor: number): void;
  69539. createVertexArray(): any;
  69540. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69541. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69542. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69543. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69544. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69545. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69546. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69547. // Queries
  69548. createQuery(): WebGLQuery;
  69549. deleteQuery(query: WebGLQuery): void;
  69550. beginQuery(target: number, query: WebGLQuery): void;
  69551. endQuery(target: number): void;
  69552. getQueryParameter(query: WebGLQuery, pname: number): any;
  69553. getQuery(target: number, pname: number): any;
  69554. MAX_SAMPLES: number;
  69555. RGBA8: number;
  69556. READ_FRAMEBUFFER: number;
  69557. DRAW_FRAMEBUFFER: number;
  69558. UNIFORM_BUFFER: number;
  69559. HALF_FLOAT_OES: number;
  69560. RGBA16F: number;
  69561. RGBA32F: number;
  69562. R32F: number;
  69563. RG32F: number;
  69564. RGB32F: number;
  69565. R16F: number;
  69566. RG16F: number;
  69567. RGB16F: number;
  69568. RED: number;
  69569. RG: number;
  69570. R8: number;
  69571. RG8: number;
  69572. UNSIGNED_INT_24_8: number;
  69573. DEPTH24_STENCIL8: number;
  69574. MIN: number;
  69575. MAX: number;
  69576. /* Multiple Render Targets */
  69577. drawBuffers(buffers: number[]): void;
  69578. readBuffer(src: number): void;
  69579. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69580. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69581. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69582. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69583. // Occlusion Query
  69584. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69585. ANY_SAMPLES_PASSED: number;
  69586. QUERY_RESULT_AVAILABLE: number;
  69587. QUERY_RESULT: number;
  69588. }
  69589. interface WebGLProgram {
  69590. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69591. }
  69592. interface EXT_disjoint_timer_query {
  69593. QUERY_COUNTER_BITS_EXT: number;
  69594. TIME_ELAPSED_EXT: number;
  69595. TIMESTAMP_EXT: number;
  69596. GPU_DISJOINT_EXT: number;
  69597. QUERY_RESULT_EXT: number;
  69598. QUERY_RESULT_AVAILABLE_EXT: number;
  69599. queryCounterEXT(query: WebGLQuery, target: number): void;
  69600. createQueryEXT(): WebGLQuery;
  69601. beginQueryEXT(target: number, query: WebGLQuery): void;
  69602. endQueryEXT(target: number): void;
  69603. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69604. deleteQueryEXT(query: WebGLQuery): void;
  69605. }
  69606. interface WebGLUniformLocation {
  69607. _currentState: any;
  69608. }
  69609. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69610. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69611. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69612. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69613. interface WebGLRenderingContext {
  69614. readonly RASTERIZER_DISCARD: number;
  69615. readonly DEPTH_COMPONENT24: number;
  69616. readonly TEXTURE_3D: number;
  69617. readonly TEXTURE_2D_ARRAY: number;
  69618. readonly TEXTURE_COMPARE_FUNC: number;
  69619. readonly TEXTURE_COMPARE_MODE: number;
  69620. readonly COMPARE_REF_TO_TEXTURE: number;
  69621. readonly TEXTURE_WRAP_R: number;
  69622. readonly HALF_FLOAT: number;
  69623. readonly RGB8: number;
  69624. readonly RED_INTEGER: number;
  69625. readonly RG_INTEGER: number;
  69626. readonly RGB_INTEGER: number;
  69627. readonly RGBA_INTEGER: number;
  69628. readonly R8_SNORM: number;
  69629. readonly RG8_SNORM: number;
  69630. readonly RGB8_SNORM: number;
  69631. readonly RGBA8_SNORM: number;
  69632. readonly R8I: number;
  69633. readonly RG8I: number;
  69634. readonly RGB8I: number;
  69635. readonly RGBA8I: number;
  69636. readonly R8UI: number;
  69637. readonly RG8UI: number;
  69638. readonly RGB8UI: number;
  69639. readonly RGBA8UI: number;
  69640. readonly R16I: number;
  69641. readonly RG16I: number;
  69642. readonly RGB16I: number;
  69643. readonly RGBA16I: number;
  69644. readonly R16UI: number;
  69645. readonly RG16UI: number;
  69646. readonly RGB16UI: number;
  69647. readonly RGBA16UI: number;
  69648. readonly R32I: number;
  69649. readonly RG32I: number;
  69650. readonly RGB32I: number;
  69651. readonly RGBA32I: number;
  69652. readonly R32UI: number;
  69653. readonly RG32UI: number;
  69654. readonly RGB32UI: number;
  69655. readonly RGBA32UI: number;
  69656. readonly RGB10_A2UI: number;
  69657. readonly R11F_G11F_B10F: number;
  69658. readonly RGB9_E5: number;
  69659. readonly RGB10_A2: number;
  69660. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69661. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69662. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69663. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69664. readonly DEPTH_COMPONENT32F: number;
  69665. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69666. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69667. 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;
  69668. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69669. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69670. readonly TRANSFORM_FEEDBACK: number;
  69671. readonly INTERLEAVED_ATTRIBS: number;
  69672. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69673. createTransformFeedback(): WebGLTransformFeedback;
  69674. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69675. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69676. beginTransformFeedback(primitiveMode: number): void;
  69677. endTransformFeedback(): void;
  69678. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69679. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69680. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69681. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69682. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69683. }
  69684. interface ImageBitmap {
  69685. readonly width: number;
  69686. readonly height: number;
  69687. close(): void;
  69688. }
  69689. interface WebGLQuery extends WebGLObject {
  69690. }
  69691. declare var WebGLQuery: {
  69692. prototype: WebGLQuery;
  69693. new(): WebGLQuery;
  69694. };
  69695. interface WebGLSampler extends WebGLObject {
  69696. }
  69697. declare var WebGLSampler: {
  69698. prototype: WebGLSampler;
  69699. new(): WebGLSampler;
  69700. };
  69701. interface WebGLSync extends WebGLObject {
  69702. }
  69703. declare var WebGLSync: {
  69704. prototype: WebGLSync;
  69705. new(): WebGLSync;
  69706. };
  69707. interface WebGLTransformFeedback extends WebGLObject {
  69708. }
  69709. declare var WebGLTransformFeedback: {
  69710. prototype: WebGLTransformFeedback;
  69711. new(): WebGLTransformFeedback;
  69712. };
  69713. interface WebGLVertexArrayObject extends WebGLObject {
  69714. }
  69715. declare var WebGLVertexArrayObject: {
  69716. prototype: WebGLVertexArrayObject;
  69717. new(): WebGLVertexArrayObject;
  69718. };
  69719. // Type definitions for WebVR API
  69720. // Project: https://w3c.github.io/webvr/
  69721. // Definitions by: six a <https://github.com/lostfictions>
  69722. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69723. interface VRDisplay extends EventTarget {
  69724. /**
  69725. * Dictionary of capabilities describing the VRDisplay.
  69726. */
  69727. readonly capabilities: VRDisplayCapabilities;
  69728. /**
  69729. * z-depth defining the far plane of the eye view frustum
  69730. * enables mapping of values in the render target depth
  69731. * attachment to scene coordinates. Initially set to 10000.0.
  69732. */
  69733. depthFar: number;
  69734. /**
  69735. * z-depth defining the near plane of the eye view frustum
  69736. * enables mapping of values in the render target depth
  69737. * attachment to scene coordinates. Initially set to 0.01.
  69738. */
  69739. depthNear: number;
  69740. /**
  69741. * An identifier for this distinct VRDisplay. Used as an
  69742. * association point in the Gamepad API.
  69743. */
  69744. readonly displayId: number;
  69745. /**
  69746. * A display name, a user-readable name identifying it.
  69747. */
  69748. readonly displayName: string;
  69749. readonly isConnected: boolean;
  69750. readonly isPresenting: boolean;
  69751. /**
  69752. * If this VRDisplay supports room-scale experiences, the optional
  69753. * stage attribute contains details on the room-scale parameters.
  69754. */
  69755. readonly stageParameters: VRStageParameters | null;
  69756. /**
  69757. * Passing the value returned by `requestAnimationFrame` to
  69758. * `cancelAnimationFrame` will unregister the callback.
  69759. * @param handle Define the hanle of the request to cancel
  69760. */
  69761. cancelAnimationFrame(handle: number): void;
  69762. /**
  69763. * Stops presenting to the VRDisplay.
  69764. * @returns a promise to know when it stopped
  69765. */
  69766. exitPresent(): Promise<void>;
  69767. /**
  69768. * Return the current VREyeParameters for the given eye.
  69769. * @param whichEye Define the eye we want the parameter for
  69770. * @returns the eye parameters
  69771. */
  69772. getEyeParameters(whichEye: string): VREyeParameters;
  69773. /**
  69774. * Populates the passed VRFrameData with the information required to render
  69775. * the current frame.
  69776. * @param frameData Define the data structure to populate
  69777. * @returns true if ok otherwise false
  69778. */
  69779. getFrameData(frameData: VRFrameData): boolean;
  69780. /**
  69781. * Get the layers currently being presented.
  69782. * @returns the list of VR layers
  69783. */
  69784. getLayers(): VRLayer[];
  69785. /**
  69786. * Return a VRPose containing the future predicted pose of the VRDisplay
  69787. * when the current frame will be presented. The value returned will not
  69788. * change until JavaScript has returned control to the browser.
  69789. *
  69790. * The VRPose will contain the position, orientation, velocity,
  69791. * and acceleration of each of these properties.
  69792. * @returns the pose object
  69793. */
  69794. getPose(): VRPose;
  69795. /**
  69796. * Return the current instantaneous pose of the VRDisplay, with no
  69797. * prediction applied.
  69798. * @returns the current instantaneous pose
  69799. */
  69800. getImmediatePose(): VRPose;
  69801. /**
  69802. * The callback passed to `requestAnimationFrame` will be called
  69803. * any time a new frame should be rendered. When the VRDisplay is
  69804. * presenting the callback will be called at the native refresh
  69805. * rate of the HMD. When not presenting this function acts
  69806. * identically to how window.requestAnimationFrame acts. Content should
  69807. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69808. * asynchronously from other displays and at differing refresh rates.
  69809. * @param callback Define the eaction to run next frame
  69810. * @returns the request handle it
  69811. */
  69812. requestAnimationFrame(callback: FrameRequestCallback): number;
  69813. /**
  69814. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69815. * Repeat calls while already presenting will update the VRLayers being displayed.
  69816. * @param layers Define the list of layer to present
  69817. * @returns a promise to know when the request has been fulfilled
  69818. */
  69819. requestPresent(layers: VRLayer[]): Promise<void>;
  69820. /**
  69821. * Reset the pose for this display, treating its current position and
  69822. * orientation as the "origin/zero" values. VRPose.position,
  69823. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69824. * updated when calling resetPose(). This should be called in only
  69825. * sitting-space experiences.
  69826. */
  69827. resetPose(): void;
  69828. /**
  69829. * The VRLayer provided to the VRDisplay will be captured and presented
  69830. * in the HMD. Calling this function has the same effect on the source
  69831. * canvas as any other operation that uses its source image, and canvases
  69832. * created without preserveDrawingBuffer set to true will be cleared.
  69833. * @param pose Define the pose to submit
  69834. */
  69835. submitFrame(pose?: VRPose): void;
  69836. }
  69837. declare var VRDisplay: {
  69838. prototype: VRDisplay;
  69839. new(): VRDisplay;
  69840. };
  69841. interface VRLayer {
  69842. leftBounds?: number[] | Float32Array | null;
  69843. rightBounds?: number[] | Float32Array | null;
  69844. source?: HTMLCanvasElement | null;
  69845. }
  69846. interface VRDisplayCapabilities {
  69847. readonly canPresent: boolean;
  69848. readonly hasExternalDisplay: boolean;
  69849. readonly hasOrientation: boolean;
  69850. readonly hasPosition: boolean;
  69851. readonly maxLayers: number;
  69852. }
  69853. interface VREyeParameters {
  69854. /** @deprecated */
  69855. readonly fieldOfView: VRFieldOfView;
  69856. readonly offset: Float32Array;
  69857. readonly renderHeight: number;
  69858. readonly renderWidth: number;
  69859. }
  69860. interface VRFieldOfView {
  69861. readonly downDegrees: number;
  69862. readonly leftDegrees: number;
  69863. readonly rightDegrees: number;
  69864. readonly upDegrees: number;
  69865. }
  69866. interface VRFrameData {
  69867. readonly leftProjectionMatrix: Float32Array;
  69868. readonly leftViewMatrix: Float32Array;
  69869. readonly pose: VRPose;
  69870. readonly rightProjectionMatrix: Float32Array;
  69871. readonly rightViewMatrix: Float32Array;
  69872. readonly timestamp: number;
  69873. }
  69874. interface VRPose {
  69875. readonly angularAcceleration: Float32Array | null;
  69876. readonly angularVelocity: Float32Array | null;
  69877. readonly linearAcceleration: Float32Array | null;
  69878. readonly linearVelocity: Float32Array | null;
  69879. readonly orientation: Float32Array | null;
  69880. readonly position: Float32Array | null;
  69881. readonly timestamp: number;
  69882. }
  69883. interface VRStageParameters {
  69884. sittingToStandingTransform?: Float32Array;
  69885. sizeX?: number;
  69886. sizeY?: number;
  69887. }
  69888. interface Navigator {
  69889. getVRDisplays(): Promise<VRDisplay[]>;
  69890. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69891. }
  69892. interface Window {
  69893. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69894. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69895. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69896. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69897. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69898. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69899. }
  69900. interface Gamepad {
  69901. readonly displayId: number;
  69902. }
  69903. type XRSessionMode =
  69904. | "inline"
  69905. | "immersive-vr"
  69906. | "immersive-ar";
  69907. type XRReferenceSpaceType =
  69908. | "viewer"
  69909. | "local"
  69910. | "local-floor"
  69911. | "bounded-floor"
  69912. | "unbounded";
  69913. type XREnvironmentBlendMode =
  69914. | "opaque"
  69915. | "additive"
  69916. | "alpha-blend";
  69917. type XRVisibilityState =
  69918. | "visible"
  69919. | "visible-blurred"
  69920. | "hidden";
  69921. type XRHandedness =
  69922. | "none"
  69923. | "left"
  69924. | "right";
  69925. type XRTargetRayMode =
  69926. | "gaze"
  69927. | "tracked-pointer"
  69928. | "screen";
  69929. type XREye =
  69930. | "none"
  69931. | "left"
  69932. | "right";
  69933. interface XRSpace extends EventTarget {
  69934. }
  69935. interface XRRenderState {
  69936. depthNear?: number;
  69937. depthFar?: number;
  69938. inlineVerticalFieldOfView?: number;
  69939. baseLayer?: XRWebGLLayer;
  69940. }
  69941. interface XRInputSource {
  69942. handedness: XRHandedness;
  69943. targetRayMode: XRTargetRayMode;
  69944. targetRaySpace: XRSpace;
  69945. gripSpace: XRSpace | undefined;
  69946. gamepad: Gamepad | undefined;
  69947. profiles: Array<string>;
  69948. }
  69949. interface XRSessionInit {
  69950. optionalFeatures?: XRReferenceSpaceType[];
  69951. requiredFeatures?: XRReferenceSpaceType[];
  69952. }
  69953. interface XRSession extends XRAnchorCreator {
  69954. addEventListener: Function;
  69955. removeEventListener: Function;
  69956. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69957. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69958. requestAnimationFrame: Function;
  69959. end(): Promise<void>;
  69960. renderState: XRRenderState;
  69961. inputSources: Array<XRInputSource>;
  69962. // AR hit test
  69963. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69964. updateWorldTrackingState(options: {
  69965. planeDetectionState?: { enabled: boolean; }
  69966. }): void;
  69967. }
  69968. interface XRReferenceSpace extends XRSpace {
  69969. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69970. onreset: any;
  69971. }
  69972. type XRPlaneSet = Set<XRPlane>;
  69973. type XRAnchorSet = Set<XRAnchor>;
  69974. interface XRFrame {
  69975. session: XRSession;
  69976. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69977. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69978. // Anchors
  69979. trackedAnchors?: XRAnchorSet;
  69980. // Planes
  69981. worldInformation: {
  69982. detectedPlanes?: XRPlaneSet;
  69983. };
  69984. }
  69985. interface XRViewerPose extends XRPose {
  69986. views: Array<XRView>;
  69987. }
  69988. interface XRPose {
  69989. transform: XRRigidTransform;
  69990. emulatedPosition: boolean;
  69991. }
  69992. interface XRWebGLLayerOptions {
  69993. antialias?: boolean;
  69994. depth?: boolean;
  69995. stencil?: boolean;
  69996. alpha?: boolean;
  69997. multiview?: boolean;
  69998. framebufferScaleFactor?: number;
  69999. }
  70000. declare var XRWebGLLayer: {
  70001. prototype: XRWebGLLayer;
  70002. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  70003. };
  70004. interface XRWebGLLayer {
  70005. framebuffer: WebGLFramebuffer;
  70006. framebufferWidth: number;
  70007. framebufferHeight: number;
  70008. getViewport: Function;
  70009. }
  70010. declare class XRRigidTransform {
  70011. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  70012. position: DOMPointReadOnly;
  70013. orientation: DOMPointReadOnly;
  70014. matrix: Float32Array;
  70015. inverse: XRRigidTransform;
  70016. }
  70017. interface XRView {
  70018. eye: XREye;
  70019. projectionMatrix: Float32Array;
  70020. transform: XRRigidTransform;
  70021. }
  70022. interface XRInputSourceChangeEvent {
  70023. session: XRSession;
  70024. removed: Array<XRInputSource>;
  70025. added: Array<XRInputSource>;
  70026. }
  70027. interface XRInputSourceEvent extends Event {
  70028. readonly frame: XRFrame;
  70029. readonly inputSource: XRInputSource;
  70030. }
  70031. // Experimental(er) features
  70032. declare class XRRay {
  70033. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  70034. origin: DOMPointReadOnly;
  70035. direction: DOMPointReadOnly;
  70036. matrix: Float32Array;
  70037. }
  70038. interface XRHitResult {
  70039. hitMatrix: Float32Array;
  70040. }
  70041. interface XRAnchor {
  70042. // remove?
  70043. id?: string;
  70044. anchorSpace: XRSpace;
  70045. lastChangedTime: number;
  70046. detach(): void;
  70047. }
  70048. interface XRPlane extends XRAnchorCreator {
  70049. orientation: "Horizontal" | "Vertical";
  70050. planeSpace: XRSpace;
  70051. polygon: Array<DOMPointReadOnly>;
  70052. lastChangedTime: number;
  70053. }
  70054. interface XRAnchorCreator {
  70055. // AR Anchors
  70056. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  70057. }
  70058. /**
  70059. * @ignore
  70060. */
  70061. declare module BABYLON.GLTF2.Exporter {
  70062. }
  70063. /**
  70064. * @ignore
  70065. */
  70066. declare module BABYLON.GLTF1 {
  70067. }
  70068. declare module BABYLON.GUI {
  70069. /**
  70070. * Class used to specific a value and its associated unit
  70071. */
  70072. export class ValueAndUnit {
  70073. /** defines the unit to store */
  70074. unit: number;
  70075. /** defines a boolean indicating if the value can be negative */
  70076. negativeValueAllowed: boolean;
  70077. private _value;
  70078. private _originalUnit;
  70079. /**
  70080. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  70081. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70082. */
  70083. ignoreAdaptiveScaling: boolean;
  70084. /**
  70085. * Creates a new ValueAndUnit
  70086. * @param value defines the value to store
  70087. * @param unit defines the unit to store
  70088. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  70089. */
  70090. constructor(value: number,
  70091. /** defines the unit to store */
  70092. unit?: number,
  70093. /** defines a boolean indicating if the value can be negative */
  70094. negativeValueAllowed?: boolean);
  70095. /** Gets a boolean indicating if the value is a percentage */
  70096. get isPercentage(): boolean;
  70097. /** Gets a boolean indicating if the value is store as pixel */
  70098. get isPixel(): boolean;
  70099. /** Gets direct internal value */
  70100. get internalValue(): number;
  70101. /**
  70102. * Gets value as pixel
  70103. * @param host defines the root host
  70104. * @param refValue defines the reference value for percentages
  70105. * @returns the value as pixel
  70106. */
  70107. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70108. /**
  70109. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70110. * @param value defines the value to store
  70111. * @param unit defines the unit to store
  70112. * @returns the current ValueAndUnit
  70113. */
  70114. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70115. /**
  70116. * Gets the value accordingly to its unit
  70117. * @param host defines the root host
  70118. * @returns the value
  70119. */
  70120. getValue(host: AdvancedDynamicTexture): number;
  70121. /**
  70122. * Gets a string representation of the value
  70123. * @param host defines the root host
  70124. * @param decimals defines an optional number of decimals to display
  70125. * @returns a string
  70126. */
  70127. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70128. /**
  70129. * Store a value parsed from a string
  70130. * @param source defines the source string
  70131. * @returns true if the value was successfully parsed
  70132. */
  70133. fromString(source: string | number): boolean;
  70134. private static _Regex;
  70135. private static _UNITMODE_PERCENTAGE;
  70136. private static _UNITMODE_PIXEL;
  70137. /** UNITMODE_PERCENTAGE */
  70138. static get UNITMODE_PERCENTAGE(): number;
  70139. /** UNITMODE_PIXEL */
  70140. static get UNITMODE_PIXEL(): number;
  70141. }
  70142. }
  70143. declare module BABYLON.GUI {
  70144. /**
  70145. * Define a style used by control to automatically setup properties based on a template.
  70146. * Only support font related properties so far
  70147. */
  70148. export class Style implements BABYLON.IDisposable {
  70149. private _fontFamily;
  70150. private _fontStyle;
  70151. private _fontWeight;
  70152. /** @hidden */
  70153. _host: AdvancedDynamicTexture;
  70154. /** @hidden */
  70155. _fontSize: ValueAndUnit;
  70156. /**
  70157. * BABYLON.Observable raised when the style values are changed
  70158. */
  70159. onChangedObservable: BABYLON.Observable<Style>;
  70160. /**
  70161. * Creates a new style object
  70162. * @param host defines the AdvancedDynamicTexture which hosts this style
  70163. */
  70164. constructor(host: AdvancedDynamicTexture);
  70165. /**
  70166. * Gets or sets the font size
  70167. */
  70168. get fontSize(): string | number;
  70169. set fontSize(value: string | number);
  70170. /**
  70171. * Gets or sets the font family
  70172. */
  70173. get fontFamily(): string;
  70174. set fontFamily(value: string);
  70175. /**
  70176. * Gets or sets the font style
  70177. */
  70178. get fontStyle(): string;
  70179. set fontStyle(value: string);
  70180. /** Gets or sets font weight */
  70181. get fontWeight(): string;
  70182. set fontWeight(value: string);
  70183. /** Dispose all associated resources */
  70184. dispose(): void;
  70185. }
  70186. }
  70187. declare module BABYLON.GUI {
  70188. /**
  70189. * Class used to transport BABYLON.Vector2 information for pointer events
  70190. */
  70191. export class Vector2WithInfo extends BABYLON.Vector2 {
  70192. /** defines the current mouse button index */
  70193. buttonIndex: number;
  70194. /**
  70195. * Creates a new Vector2WithInfo
  70196. * @param source defines the vector2 data to transport
  70197. * @param buttonIndex defines the current mouse button index
  70198. */
  70199. constructor(source: BABYLON.Vector2,
  70200. /** defines the current mouse button index */
  70201. buttonIndex?: number);
  70202. }
  70203. /** Class used to provide 2D matrix features */
  70204. export class Matrix2D {
  70205. /** Gets the internal array of 6 floats used to store matrix data */
  70206. m: Float32Array;
  70207. /**
  70208. * Creates a new matrix
  70209. * @param m00 defines value for (0, 0)
  70210. * @param m01 defines value for (0, 1)
  70211. * @param m10 defines value for (1, 0)
  70212. * @param m11 defines value for (1, 1)
  70213. * @param m20 defines value for (2, 0)
  70214. * @param m21 defines value for (2, 1)
  70215. */
  70216. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70217. /**
  70218. * Fills the matrix from direct values
  70219. * @param m00 defines value for (0, 0)
  70220. * @param m01 defines value for (0, 1)
  70221. * @param m10 defines value for (1, 0)
  70222. * @param m11 defines value for (1, 1)
  70223. * @param m20 defines value for (2, 0)
  70224. * @param m21 defines value for (2, 1)
  70225. * @returns the current modified matrix
  70226. */
  70227. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70228. /**
  70229. * Gets matrix determinant
  70230. * @returns the determinant
  70231. */
  70232. determinant(): number;
  70233. /**
  70234. * Inverses the matrix and stores it in a target matrix
  70235. * @param result defines the target matrix
  70236. * @returns the current matrix
  70237. */
  70238. invertToRef(result: Matrix2D): Matrix2D;
  70239. /**
  70240. * Multiplies the current matrix with another one
  70241. * @param other defines the second operand
  70242. * @param result defines the target matrix
  70243. * @returns the current matrix
  70244. */
  70245. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70246. /**
  70247. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70248. * @param x defines the x coordinate to transform
  70249. * @param y defines the x coordinate to transform
  70250. * @param result defines the target vector2
  70251. * @returns the current matrix
  70252. */
  70253. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70254. /**
  70255. * Creates an identity matrix
  70256. * @returns a new matrix
  70257. */
  70258. static Identity(): Matrix2D;
  70259. /**
  70260. * Creates a translation matrix and stores it in a target matrix
  70261. * @param x defines the x coordinate of the translation
  70262. * @param y defines the y coordinate of the translation
  70263. * @param result defines the target matrix
  70264. */
  70265. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70266. /**
  70267. * Creates a scaling matrix and stores it in a target matrix
  70268. * @param x defines the x coordinate of the scaling
  70269. * @param y defines the y coordinate of the scaling
  70270. * @param result defines the target matrix
  70271. */
  70272. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70273. /**
  70274. * Creates a rotation matrix and stores it in a target matrix
  70275. * @param angle defines the rotation angle
  70276. * @param result defines the target matrix
  70277. */
  70278. static RotationToRef(angle: number, result: Matrix2D): void;
  70279. private static _TempPreTranslationMatrix;
  70280. private static _TempPostTranslationMatrix;
  70281. private static _TempRotationMatrix;
  70282. private static _TempScalingMatrix;
  70283. private static _TempCompose0;
  70284. private static _TempCompose1;
  70285. private static _TempCompose2;
  70286. /**
  70287. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70288. * @param tx defines the x coordinate of the translation
  70289. * @param ty defines the y coordinate of the translation
  70290. * @param angle defines the rotation angle
  70291. * @param scaleX defines the x coordinate of the scaling
  70292. * @param scaleY defines the y coordinate of the scaling
  70293. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70294. * @param result defines the target matrix
  70295. */
  70296. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70297. }
  70298. }
  70299. declare module BABYLON.GUI {
  70300. /**
  70301. * Class used to store 2D control sizes
  70302. */
  70303. export class Measure {
  70304. /** defines left coordinate */
  70305. left: number;
  70306. /** defines top coordinate */
  70307. top: number;
  70308. /** defines width dimension */
  70309. width: number;
  70310. /** defines height dimension */
  70311. height: number;
  70312. /**
  70313. * Creates a new measure
  70314. * @param left defines left coordinate
  70315. * @param top defines top coordinate
  70316. * @param width defines width dimension
  70317. * @param height defines height dimension
  70318. */
  70319. constructor(
  70320. /** defines left coordinate */
  70321. left: number,
  70322. /** defines top coordinate */
  70323. top: number,
  70324. /** defines width dimension */
  70325. width: number,
  70326. /** defines height dimension */
  70327. height: number);
  70328. /**
  70329. * Copy from another measure
  70330. * @param other defines the other measure to copy from
  70331. */
  70332. copyFrom(other: Measure): void;
  70333. /**
  70334. * Copy from a group of 4 floats
  70335. * @param left defines left coordinate
  70336. * @param top defines top coordinate
  70337. * @param width defines width dimension
  70338. * @param height defines height dimension
  70339. */
  70340. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70341. /**
  70342. * Computes the axis aligned bounding box measure for two given measures
  70343. * @param a Input measure
  70344. * @param b Input measure
  70345. * @param result the resulting bounding measure
  70346. */
  70347. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70348. /**
  70349. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70350. * @param transform the matrix to transform the measure before computing the AABB
  70351. * @param result the resulting AABB
  70352. */
  70353. transformToRef(transform: Matrix2D, result: Measure): void;
  70354. /**
  70355. * Check equality between this measure and another one
  70356. * @param other defines the other measures
  70357. * @returns true if both measures are equals
  70358. */
  70359. isEqualsTo(other: Measure): boolean;
  70360. /**
  70361. * Creates an empty measure
  70362. * @returns a new measure
  70363. */
  70364. static Empty(): Measure;
  70365. }
  70366. }
  70367. declare module BABYLON.GUI {
  70368. /**
  70369. * Interface used to define a control that can receive focus
  70370. */
  70371. export interface IFocusableControl {
  70372. /**
  70373. * Function called when the control receives the focus
  70374. */
  70375. onFocus(): void;
  70376. /**
  70377. * Function called when the control loses the focus
  70378. */
  70379. onBlur(): void;
  70380. /**
  70381. * Function called to let the control handle keyboard events
  70382. * @param evt defines the current keyboard event
  70383. */
  70384. processKeyboard(evt: KeyboardEvent): void;
  70385. /**
  70386. * Function called to get the list of controls that should not steal the focus from this control
  70387. * @returns an array of controls
  70388. */
  70389. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70390. }
  70391. /**
  70392. * Class used to create texture to support 2D GUI elements
  70393. * @see http://doc.babylonjs.com/how_to/gui
  70394. */
  70395. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70396. private _isDirty;
  70397. private _renderObserver;
  70398. private _resizeObserver;
  70399. private _preKeyboardObserver;
  70400. private _pointerMoveObserver;
  70401. private _pointerObserver;
  70402. private _canvasPointerOutObserver;
  70403. private _background;
  70404. /** @hidden */
  70405. _rootContainer: Container;
  70406. /** @hidden */
  70407. _lastPickedControl: Control;
  70408. /** @hidden */
  70409. _lastControlOver: {
  70410. [pointerId: number]: Control;
  70411. };
  70412. /** @hidden */
  70413. _lastControlDown: {
  70414. [pointerId: number]: Control;
  70415. };
  70416. /** @hidden */
  70417. _capturingControl: {
  70418. [pointerId: number]: Control;
  70419. };
  70420. /** @hidden */
  70421. _shouldBlockPointer: boolean;
  70422. /** @hidden */
  70423. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70424. /** @hidden */
  70425. _linkedControls: Control[];
  70426. private _isFullscreen;
  70427. private _fullscreenViewport;
  70428. private _idealWidth;
  70429. private _idealHeight;
  70430. private _useSmallestIdeal;
  70431. private _renderAtIdealSize;
  70432. private _focusedControl;
  70433. private _blockNextFocusCheck;
  70434. private _renderScale;
  70435. private _rootElement;
  70436. private _cursorChanged;
  70437. /** @hidden */
  70438. _numLayoutCalls: number;
  70439. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70440. get numLayoutCalls(): number;
  70441. /** @hidden */
  70442. _numRenderCalls: number;
  70443. /** Gets the number of render calls made the last time the ADT has been rendered */
  70444. get numRenderCalls(): number;
  70445. /**
  70446. * Define type to string to ensure compatibility across browsers
  70447. * Safari doesn't support DataTransfer constructor
  70448. */
  70449. private _clipboardData;
  70450. /**
  70451. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70452. */
  70453. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70454. /**
  70455. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70456. */
  70457. onControlPickedObservable: BABYLON.Observable<Control>;
  70458. /**
  70459. * BABYLON.Observable event triggered before layout is evaluated
  70460. */
  70461. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70462. /**
  70463. * BABYLON.Observable event triggered after the layout was evaluated
  70464. */
  70465. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70466. /**
  70467. * BABYLON.Observable event triggered before the texture is rendered
  70468. */
  70469. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70470. /**
  70471. * BABYLON.Observable event triggered after the texture was rendered
  70472. */
  70473. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70474. /**
  70475. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70476. */
  70477. premulAlpha: boolean;
  70478. /**
  70479. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70480. * Useful when you want more antialiasing
  70481. */
  70482. get renderScale(): number;
  70483. set renderScale(value: number);
  70484. /** Gets or sets the background color */
  70485. get background(): string;
  70486. set background(value: string);
  70487. /**
  70488. * Gets or sets the ideal width used to design controls.
  70489. * The GUI will then rescale everything accordingly
  70490. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70491. */
  70492. get idealWidth(): number;
  70493. set idealWidth(value: number);
  70494. /**
  70495. * Gets or sets the ideal height used to design controls.
  70496. * The GUI will then rescale everything accordingly
  70497. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70498. */
  70499. get idealHeight(): number;
  70500. set idealHeight(value: number);
  70501. /**
  70502. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70503. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70504. */
  70505. get useSmallestIdeal(): boolean;
  70506. set useSmallestIdeal(value: boolean);
  70507. /**
  70508. * Gets or sets a boolean indicating if adaptive scaling must be used
  70509. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70510. */
  70511. get renderAtIdealSize(): boolean;
  70512. set renderAtIdealSize(value: boolean);
  70513. /**
  70514. * Gets the ratio used when in "ideal mode"
  70515. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70516. * */
  70517. get idealRatio(): number;
  70518. /**
  70519. * Gets the underlying layer used to render the texture when in fullscreen mode
  70520. */
  70521. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70522. /**
  70523. * Gets the root container control
  70524. */
  70525. get rootContainer(): Container;
  70526. /**
  70527. * Returns an array containing the root container.
  70528. * This is mostly used to let the Inspector introspects the ADT
  70529. * @returns an array containing the rootContainer
  70530. */
  70531. getChildren(): Array<Container>;
  70532. /**
  70533. * Will return all controls that are inside this texture
  70534. * @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
  70535. * @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
  70536. * @return all child controls
  70537. */
  70538. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70539. /**
  70540. * Gets or sets the current focused control
  70541. */
  70542. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70543. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70544. /**
  70545. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70546. */
  70547. get isForeground(): boolean;
  70548. set isForeground(value: boolean);
  70549. /**
  70550. * Gets or set information about clipboardData
  70551. */
  70552. get clipboardData(): string;
  70553. set clipboardData(value: string);
  70554. /**
  70555. * Creates a new AdvancedDynamicTexture
  70556. * @param name defines the name of the texture
  70557. * @param width defines the width of the texture
  70558. * @param height defines the height of the texture
  70559. * @param scene defines the hosting scene
  70560. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70561. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70562. */
  70563. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70564. /**
  70565. * Get the current class name of the texture useful for serialization or dynamic coding.
  70566. * @returns "AdvancedDynamicTexture"
  70567. */
  70568. getClassName(): string;
  70569. /**
  70570. * Function used to execute a function on all controls
  70571. * @param func defines the function to execute
  70572. * @param container defines the container where controls belong. If null the root container will be used
  70573. */
  70574. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70575. private _useInvalidateRectOptimization;
  70576. /**
  70577. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70578. */
  70579. get useInvalidateRectOptimization(): boolean;
  70580. set useInvalidateRectOptimization(value: boolean);
  70581. private _invalidatedRectangle;
  70582. /**
  70583. * Invalidates a rectangle area on the gui texture
  70584. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70585. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70586. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70587. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70588. */
  70589. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70590. /**
  70591. * Marks the texture as dirty forcing a complete update
  70592. */
  70593. markAsDirty(): void;
  70594. /**
  70595. * Helper function used to create a new style
  70596. * @returns a new style
  70597. * @see http://doc.babylonjs.com/how_to/gui#styles
  70598. */
  70599. createStyle(): Style;
  70600. /**
  70601. * Adds a new control to the root container
  70602. * @param control defines the control to add
  70603. * @returns the current texture
  70604. */
  70605. addControl(control: Control): AdvancedDynamicTexture;
  70606. /**
  70607. * Removes a control from the root container
  70608. * @param control defines the control to remove
  70609. * @returns the current texture
  70610. */
  70611. removeControl(control: Control): AdvancedDynamicTexture;
  70612. /**
  70613. * Release all resources
  70614. */
  70615. dispose(): void;
  70616. private _onResize;
  70617. /** @hidden */
  70618. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70619. /**
  70620. * Get screen coordinates for a vector3
  70621. * @param position defines the position to project
  70622. * @param worldMatrix defines the world matrix to use
  70623. * @returns the projected position
  70624. */
  70625. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70626. private _checkUpdate;
  70627. private _clearMeasure;
  70628. private _render;
  70629. /** @hidden */
  70630. _changeCursor(cursor: string): void;
  70631. /** @hidden */
  70632. _registerLastControlDown(control: Control, pointerId: number): void;
  70633. private _doPicking;
  70634. /** @hidden */
  70635. _cleanControlAfterRemovalFromList(list: {
  70636. [pointerId: number]: Control;
  70637. }, control: Control): void;
  70638. /** @hidden */
  70639. _cleanControlAfterRemoval(control: Control): void;
  70640. /** Attach to all scene events required to support pointer events */
  70641. attach(): void;
  70642. /** @hidden */
  70643. private onClipboardCopy;
  70644. /** @hidden */
  70645. private onClipboardCut;
  70646. /** @hidden */
  70647. private onClipboardPaste;
  70648. /**
  70649. * Register the clipboard Events onto the canvas
  70650. */
  70651. registerClipboardEvents(): void;
  70652. /**
  70653. * Unregister the clipboard Events from the canvas
  70654. */
  70655. unRegisterClipboardEvents(): void;
  70656. /**
  70657. * Connect the texture to a hosting mesh to enable interactions
  70658. * @param mesh defines the mesh to attach to
  70659. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70660. */
  70661. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70662. /**
  70663. * Move the focus to a specific control
  70664. * @param control defines the control which will receive the focus
  70665. */
  70666. moveFocusToControl(control: IFocusableControl): void;
  70667. private _manageFocus;
  70668. private _attachToOnPointerOut;
  70669. /**
  70670. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70671. * @param mesh defines the mesh which will receive the texture
  70672. * @param width defines the texture width (1024 by default)
  70673. * @param height defines the texture height (1024 by default)
  70674. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70675. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70676. * @returns a new AdvancedDynamicTexture
  70677. */
  70678. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70679. /**
  70680. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70681. * In this mode the texture will rely on a layer for its rendering.
  70682. * This allows it to be treated like any other layer.
  70683. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70684. * LayerMask is set through advancedTexture.layer.layerMask
  70685. * @param name defines name for the texture
  70686. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70687. * @param scene defines the hsoting scene
  70688. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70689. * @returns a new AdvancedDynamicTexture
  70690. */
  70691. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70692. }
  70693. }
  70694. declare module BABYLON.GUI {
  70695. /**
  70696. * Root class used for all 2D controls
  70697. * @see http://doc.babylonjs.com/how_to/gui#controls
  70698. */
  70699. export class Control {
  70700. /** defines the name of the control */
  70701. name?: string | undefined;
  70702. /**
  70703. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70704. */
  70705. static AllowAlphaInheritance: boolean;
  70706. private _alpha;
  70707. private _alphaSet;
  70708. private _zIndex;
  70709. /** @hidden */
  70710. _host: AdvancedDynamicTexture;
  70711. /** Gets or sets the control parent */
  70712. parent: BABYLON.Nullable<Container>;
  70713. /** @hidden */
  70714. _currentMeasure: Measure;
  70715. private _fontFamily;
  70716. private _fontStyle;
  70717. private _fontWeight;
  70718. private _fontSize;
  70719. private _font;
  70720. /** @hidden */
  70721. _width: ValueAndUnit;
  70722. /** @hidden */
  70723. _height: ValueAndUnit;
  70724. /** @hidden */
  70725. protected _fontOffset: {
  70726. ascent: number;
  70727. height: number;
  70728. descent: number;
  70729. };
  70730. private _color;
  70731. private _style;
  70732. private _styleObserver;
  70733. /** @hidden */
  70734. protected _horizontalAlignment: number;
  70735. /** @hidden */
  70736. protected _verticalAlignment: number;
  70737. /** @hidden */
  70738. protected _isDirty: boolean;
  70739. /** @hidden */
  70740. protected _wasDirty: boolean;
  70741. /** @hidden */
  70742. _tempParentMeasure: Measure;
  70743. /** @hidden */
  70744. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70745. /** @hidden */
  70746. protected _cachedParentMeasure: Measure;
  70747. private _paddingLeft;
  70748. private _paddingRight;
  70749. private _paddingTop;
  70750. private _paddingBottom;
  70751. /** @hidden */
  70752. _left: ValueAndUnit;
  70753. /** @hidden */
  70754. _top: ValueAndUnit;
  70755. private _scaleX;
  70756. private _scaleY;
  70757. private _rotation;
  70758. private _transformCenterX;
  70759. private _transformCenterY;
  70760. /** @hidden */
  70761. _transformMatrix: Matrix2D;
  70762. /** @hidden */
  70763. protected _invertTransformMatrix: Matrix2D;
  70764. /** @hidden */
  70765. protected _transformedPosition: BABYLON.Vector2;
  70766. private _isMatrixDirty;
  70767. private _cachedOffsetX;
  70768. private _cachedOffsetY;
  70769. private _isVisible;
  70770. private _isHighlighted;
  70771. /** @hidden */
  70772. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70773. private _fontSet;
  70774. private _dummyVector2;
  70775. private _downCount;
  70776. private _enterCount;
  70777. private _doNotRender;
  70778. private _downPointerIds;
  70779. protected _isEnabled: boolean;
  70780. protected _disabledColor: string;
  70781. /** @hidden */
  70782. protected _rebuildLayout: boolean;
  70783. /** @hidden */
  70784. _customData: any;
  70785. /** @hidden */
  70786. _isClipped: boolean;
  70787. /** @hidden */
  70788. _automaticSize: boolean;
  70789. /** @hidden */
  70790. _tag: any;
  70791. /**
  70792. * 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
  70793. */
  70794. uniqueId: number;
  70795. /**
  70796. * Gets or sets an object used to store user defined information for the node
  70797. */
  70798. metadata: any;
  70799. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70800. isHitTestVisible: boolean;
  70801. /** Gets or sets a boolean indicating if the control can block pointer events */
  70802. isPointerBlocker: boolean;
  70803. /** Gets or sets a boolean indicating if the control can be focusable */
  70804. isFocusInvisible: boolean;
  70805. /**
  70806. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70807. * 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
  70808. */
  70809. clipChildren: boolean;
  70810. /**
  70811. * Gets or sets a boolean indicating that control content must be clipped
  70812. * 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
  70813. */
  70814. clipContent: boolean;
  70815. /**
  70816. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70817. */
  70818. useBitmapCache: boolean;
  70819. private _cacheData;
  70820. private _shadowOffsetX;
  70821. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70822. get shadowOffsetX(): number;
  70823. set shadowOffsetX(value: number);
  70824. private _shadowOffsetY;
  70825. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70826. get shadowOffsetY(): number;
  70827. set shadowOffsetY(value: number);
  70828. private _shadowBlur;
  70829. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70830. get shadowBlur(): number;
  70831. set shadowBlur(value: number);
  70832. private _shadowColor;
  70833. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70834. get shadowColor(): string;
  70835. set shadowColor(value: string);
  70836. /** Gets or sets the cursor to use when the control is hovered */
  70837. hoverCursor: string;
  70838. /** @hidden */
  70839. protected _linkOffsetX: ValueAndUnit;
  70840. /** @hidden */
  70841. protected _linkOffsetY: ValueAndUnit;
  70842. /** Gets the control type name */
  70843. get typeName(): string;
  70844. /**
  70845. * Get the current class name of the control.
  70846. * @returns current class name
  70847. */
  70848. getClassName(): string;
  70849. /**
  70850. * An event triggered when the pointer move over the control.
  70851. */
  70852. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70853. /**
  70854. * An event triggered when the pointer move out of the control.
  70855. */
  70856. onPointerOutObservable: BABYLON.Observable<Control>;
  70857. /**
  70858. * An event triggered when the pointer taps the control
  70859. */
  70860. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70861. /**
  70862. * An event triggered when pointer up
  70863. */
  70864. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70865. /**
  70866. * An event triggered when a control is clicked on
  70867. */
  70868. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70869. /**
  70870. * An event triggered when pointer enters the control
  70871. */
  70872. onPointerEnterObservable: BABYLON.Observable<Control>;
  70873. /**
  70874. * An event triggered when the control is marked as dirty
  70875. */
  70876. onDirtyObservable: BABYLON.Observable<Control>;
  70877. /**
  70878. * An event triggered before drawing the control
  70879. */
  70880. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70881. /**
  70882. * An event triggered after the control was drawn
  70883. */
  70884. onAfterDrawObservable: BABYLON.Observable<Control>;
  70885. /**
  70886. * Get the hosting AdvancedDynamicTexture
  70887. */
  70888. get host(): AdvancedDynamicTexture;
  70889. /** Gets or set information about font offsets (used to render and align text) */
  70890. get fontOffset(): {
  70891. ascent: number;
  70892. height: number;
  70893. descent: number;
  70894. };
  70895. set fontOffset(offset: {
  70896. ascent: number;
  70897. height: number;
  70898. descent: number;
  70899. });
  70900. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70901. get alpha(): number;
  70902. set alpha(value: number);
  70903. /**
  70904. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70905. */
  70906. get isHighlighted(): boolean;
  70907. set isHighlighted(value: boolean);
  70908. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70909. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70910. */
  70911. get scaleX(): number;
  70912. set scaleX(value: number);
  70913. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70914. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70915. */
  70916. get scaleY(): number;
  70917. set scaleY(value: number);
  70918. /** Gets or sets the rotation angle (0 by default)
  70919. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70920. */
  70921. get rotation(): number;
  70922. set rotation(value: number);
  70923. /** Gets or sets the transformation center on Y axis (0 by default)
  70924. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70925. */
  70926. get transformCenterY(): number;
  70927. set transformCenterY(value: number);
  70928. /** Gets or sets the transformation center on X axis (0 by default)
  70929. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70930. */
  70931. get transformCenterX(): number;
  70932. set transformCenterX(value: number);
  70933. /**
  70934. * Gets or sets the horizontal alignment
  70935. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70936. */
  70937. get horizontalAlignment(): number;
  70938. set horizontalAlignment(value: number);
  70939. /**
  70940. * Gets or sets the vertical alignment
  70941. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70942. */
  70943. get verticalAlignment(): number;
  70944. set verticalAlignment(value: number);
  70945. /**
  70946. * Gets or sets control width
  70947. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70948. */
  70949. get width(): string | number;
  70950. set width(value: string | number);
  70951. /**
  70952. * Gets or sets the control width in pixel
  70953. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70954. */
  70955. get widthInPixels(): number;
  70956. set widthInPixels(value: number);
  70957. /**
  70958. * Gets or sets control height
  70959. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70960. */
  70961. get height(): string | number;
  70962. set height(value: string | number);
  70963. /**
  70964. * Gets or sets control height in pixel
  70965. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70966. */
  70967. get heightInPixels(): number;
  70968. set heightInPixels(value: number);
  70969. /** Gets or set font family */
  70970. get fontFamily(): string;
  70971. set fontFamily(value: string);
  70972. /** Gets or sets font style */
  70973. get fontStyle(): string;
  70974. set fontStyle(value: string);
  70975. /** Gets or sets font weight */
  70976. get fontWeight(): string;
  70977. set fontWeight(value: string);
  70978. /**
  70979. * Gets or sets style
  70980. * @see http://doc.babylonjs.com/how_to/gui#styles
  70981. */
  70982. get style(): BABYLON.Nullable<Style>;
  70983. set style(value: BABYLON.Nullable<Style>);
  70984. /** @hidden */
  70985. get _isFontSizeInPercentage(): boolean;
  70986. /** Gets or sets font size in pixels */
  70987. get fontSizeInPixels(): number;
  70988. set fontSizeInPixels(value: number);
  70989. /** Gets or sets font size */
  70990. get fontSize(): string | number;
  70991. set fontSize(value: string | number);
  70992. /** Gets or sets foreground color */
  70993. get color(): string;
  70994. set color(value: string);
  70995. /** Gets or sets z index which is used to reorder controls on the z axis */
  70996. get zIndex(): number;
  70997. set zIndex(value: number);
  70998. /** Gets or sets a boolean indicating if the control can be rendered */
  70999. get notRenderable(): boolean;
  71000. set notRenderable(value: boolean);
  71001. /** Gets or sets a boolean indicating if the control is visible */
  71002. get isVisible(): boolean;
  71003. set isVisible(value: boolean);
  71004. /** Gets a boolean indicating that the control needs to update its rendering */
  71005. get isDirty(): boolean;
  71006. /**
  71007. * Gets the current linked mesh (or null if none)
  71008. */
  71009. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71010. /**
  71011. * Gets or sets a value indicating the padding to use on the left of the control
  71012. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71013. */
  71014. get paddingLeft(): string | number;
  71015. set paddingLeft(value: string | number);
  71016. /**
  71017. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  71018. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71019. */
  71020. get paddingLeftInPixels(): number;
  71021. set paddingLeftInPixels(value: number);
  71022. /**
  71023. * Gets or sets a value indicating the padding to use on the right of the control
  71024. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71025. */
  71026. get paddingRight(): string | number;
  71027. set paddingRight(value: string | number);
  71028. /**
  71029. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  71030. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71031. */
  71032. get paddingRightInPixels(): number;
  71033. set paddingRightInPixels(value: number);
  71034. /**
  71035. * Gets or sets a value indicating the padding to use on the top of the control
  71036. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71037. */
  71038. get paddingTop(): string | number;
  71039. set paddingTop(value: string | number);
  71040. /**
  71041. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  71042. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71043. */
  71044. get paddingTopInPixels(): number;
  71045. set paddingTopInPixels(value: number);
  71046. /**
  71047. * Gets or sets a value indicating the padding to use on the bottom of the control
  71048. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71049. */
  71050. get paddingBottom(): string | number;
  71051. set paddingBottom(value: string | number);
  71052. /**
  71053. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  71054. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71055. */
  71056. get paddingBottomInPixels(): number;
  71057. set paddingBottomInPixels(value: number);
  71058. /**
  71059. * Gets or sets a value indicating the left coordinate of the control
  71060. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71061. */
  71062. get left(): string | number;
  71063. set left(value: string | number);
  71064. /**
  71065. * Gets or sets a value indicating the left coordinate in pixels of the control
  71066. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71067. */
  71068. get leftInPixels(): number;
  71069. set leftInPixels(value: number);
  71070. /**
  71071. * Gets or sets a value indicating the top coordinate of the control
  71072. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71073. */
  71074. get top(): string | number;
  71075. set top(value: string | number);
  71076. /**
  71077. * Gets or sets a value indicating the top coordinate in pixels of the control
  71078. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71079. */
  71080. get topInPixels(): number;
  71081. set topInPixels(value: number);
  71082. /**
  71083. * Gets or sets a value indicating the offset on X axis to the linked mesh
  71084. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71085. */
  71086. get linkOffsetX(): string | number;
  71087. set linkOffsetX(value: string | number);
  71088. /**
  71089. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  71090. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71091. */
  71092. get linkOffsetXInPixels(): number;
  71093. set linkOffsetXInPixels(value: number);
  71094. /**
  71095. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  71096. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71097. */
  71098. get linkOffsetY(): string | number;
  71099. set linkOffsetY(value: string | number);
  71100. /**
  71101. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  71102. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71103. */
  71104. get linkOffsetYInPixels(): number;
  71105. set linkOffsetYInPixels(value: number);
  71106. /** Gets the center coordinate on X axis */
  71107. get centerX(): number;
  71108. /** Gets the center coordinate on Y axis */
  71109. get centerY(): number;
  71110. /** Gets or sets if control is Enabled*/
  71111. get isEnabled(): boolean;
  71112. set isEnabled(value: boolean);
  71113. /** Gets or sets background color of control if it's disabled*/
  71114. get disabledColor(): string;
  71115. set disabledColor(value: string);
  71116. /**
  71117. * Creates a new control
  71118. * @param name defines the name of the control
  71119. */
  71120. constructor(
  71121. /** defines the name of the control */
  71122. name?: string | undefined);
  71123. /** @hidden */
  71124. protected _getTypeName(): string;
  71125. /**
  71126. * Gets the first ascendant in the hierarchy of the given type
  71127. * @param className defines the required type
  71128. * @returns the ascendant or null if not found
  71129. */
  71130. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71131. /** @hidden */
  71132. _resetFontCache(): void;
  71133. /**
  71134. * Determines if a container is an ascendant of the current control
  71135. * @param container defines the container to look for
  71136. * @returns true if the container is one of the ascendant of the control
  71137. */
  71138. isAscendant(container: Control): boolean;
  71139. /**
  71140. * Gets coordinates in local control space
  71141. * @param globalCoordinates defines the coordinates to transform
  71142. * @returns the new coordinates in local space
  71143. */
  71144. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71145. /**
  71146. * Gets coordinates in local control space
  71147. * @param globalCoordinates defines the coordinates to transform
  71148. * @param result defines the target vector2 where to store the result
  71149. * @returns the current control
  71150. */
  71151. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71152. /**
  71153. * Gets coordinates in parent local control space
  71154. * @param globalCoordinates defines the coordinates to transform
  71155. * @returns the new coordinates in parent local space
  71156. */
  71157. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71158. /**
  71159. * Move the current control to a vector3 position projected onto the screen.
  71160. * @param position defines the target position
  71161. * @param scene defines the hosting scene
  71162. */
  71163. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71164. /**
  71165. * Will store all controls that have this control as ascendant in a given array
  71166. * @param results defines the array where to store the descendants
  71167. * @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
  71168. * @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
  71169. */
  71170. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71171. /**
  71172. * Will return all controls that have this control as ascendant
  71173. * @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
  71174. * @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
  71175. * @return all child controls
  71176. */
  71177. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71178. /**
  71179. * Link current control with a target mesh
  71180. * @param mesh defines the mesh to link with
  71181. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71182. */
  71183. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71184. /** @hidden */
  71185. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71186. /** @hidden */
  71187. _offsetLeft(offset: number): void;
  71188. /** @hidden */
  71189. _offsetTop(offset: number): void;
  71190. /** @hidden */
  71191. _markMatrixAsDirty(): void;
  71192. /** @hidden */
  71193. _flagDescendantsAsMatrixDirty(): void;
  71194. /** @hidden */
  71195. _intersectsRect(rect: Measure): boolean;
  71196. /** @hidden */
  71197. protected invalidateRect(): void;
  71198. /** @hidden */
  71199. _markAsDirty(force?: boolean): void;
  71200. /** @hidden */
  71201. _markAllAsDirty(): void;
  71202. /** @hidden */
  71203. _link(host: AdvancedDynamicTexture): void;
  71204. /** @hidden */
  71205. protected _transform(context?: CanvasRenderingContext2D): void;
  71206. /** @hidden */
  71207. _renderHighlight(context: CanvasRenderingContext2D): void;
  71208. /** @hidden */
  71209. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71210. /** @hidden */
  71211. protected _applyStates(context: CanvasRenderingContext2D): void;
  71212. /** @hidden */
  71213. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71214. /** @hidden */
  71215. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71216. protected _evaluateClippingState(parentMeasure: Measure): void;
  71217. /** @hidden */
  71218. _measure(): void;
  71219. /** @hidden */
  71220. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71221. /** @hidden */
  71222. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71223. /** @hidden */
  71224. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71225. /** @hidden */
  71226. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71227. private static _ClipMeasure;
  71228. private _tmpMeasureA;
  71229. private _clip;
  71230. /** @hidden */
  71231. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71232. /** @hidden */
  71233. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71234. /**
  71235. * Tests if a given coordinates belong to the current control
  71236. * @param x defines x coordinate to test
  71237. * @param y defines y coordinate to test
  71238. * @returns true if the coordinates are inside the control
  71239. */
  71240. contains(x: number, y: number): boolean;
  71241. /** @hidden */
  71242. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71243. /** @hidden */
  71244. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71245. /** @hidden */
  71246. _onPointerEnter(target: Control): boolean;
  71247. /** @hidden */
  71248. _onPointerOut(target: Control, force?: boolean): void;
  71249. /** @hidden */
  71250. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71251. /** @hidden */
  71252. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71253. /** @hidden */
  71254. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71255. /** @hidden */
  71256. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  71257. private _prepareFont;
  71258. /** Releases associated resources */
  71259. dispose(): void;
  71260. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71261. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71262. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71263. private static _VERTICAL_ALIGNMENT_TOP;
  71264. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71265. private static _VERTICAL_ALIGNMENT_CENTER;
  71266. /** HORIZONTAL_ALIGNMENT_LEFT */
  71267. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71268. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71269. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71270. /** HORIZONTAL_ALIGNMENT_CENTER */
  71271. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71272. /** VERTICAL_ALIGNMENT_TOP */
  71273. static get VERTICAL_ALIGNMENT_TOP(): number;
  71274. /** VERTICAL_ALIGNMENT_BOTTOM */
  71275. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71276. /** VERTICAL_ALIGNMENT_CENTER */
  71277. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71278. private static _FontHeightSizes;
  71279. /** @hidden */
  71280. static _GetFontOffset(font: string): {
  71281. ascent: number;
  71282. height: number;
  71283. descent: number;
  71284. };
  71285. /**
  71286. * Creates a stack panel that can be used to render headers
  71287. * @param control defines the control to associate with the header
  71288. * @param text defines the text of the header
  71289. * @param size defines the size of the header
  71290. * @param options defines options used to configure the header
  71291. * @returns a new StackPanel
  71292. * @ignore
  71293. * @hidden
  71294. */
  71295. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71296. isHorizontal: boolean;
  71297. controlFirst: boolean;
  71298. }) => any;
  71299. /** @hidden */
  71300. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71301. }
  71302. }
  71303. declare module BABYLON.GUI {
  71304. /**
  71305. * Root class for 2D containers
  71306. * @see http://doc.babylonjs.com/how_to/gui#containers
  71307. */
  71308. export class Container extends Control {
  71309. name?: string | undefined;
  71310. /** @hidden */
  71311. _children: Control[];
  71312. /** @hidden */
  71313. protected _measureForChildren: Measure;
  71314. /** @hidden */
  71315. protected _background: string;
  71316. /** @hidden */
  71317. protected _adaptWidthToChildren: boolean;
  71318. /** @hidden */
  71319. protected _adaptHeightToChildren: boolean;
  71320. /**
  71321. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71322. */
  71323. logLayoutCycleErrors: boolean;
  71324. /**
  71325. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71326. */
  71327. maxLayoutCycle: number;
  71328. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71329. get adaptHeightToChildren(): boolean;
  71330. set adaptHeightToChildren(value: boolean);
  71331. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71332. get adaptWidthToChildren(): boolean;
  71333. set adaptWidthToChildren(value: boolean);
  71334. /** Gets or sets background color */
  71335. get background(): string;
  71336. set background(value: string);
  71337. /** Gets the list of children */
  71338. get children(): Control[];
  71339. /**
  71340. * Creates a new Container
  71341. * @param name defines the name of the container
  71342. */
  71343. constructor(name?: string | undefined);
  71344. protected _getTypeName(): string;
  71345. _flagDescendantsAsMatrixDirty(): void;
  71346. /**
  71347. * Gets a child using its name
  71348. * @param name defines the child name to look for
  71349. * @returns the child control if found
  71350. */
  71351. getChildByName(name: string): BABYLON.Nullable<Control>;
  71352. /**
  71353. * Gets a child using its type and its name
  71354. * @param name defines the child name to look for
  71355. * @param type defines the child type to look for
  71356. * @returns the child control if found
  71357. */
  71358. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71359. /**
  71360. * Search for a specific control in children
  71361. * @param control defines the control to look for
  71362. * @returns true if the control is in child list
  71363. */
  71364. containsControl(control: Control): boolean;
  71365. /**
  71366. * Adds a new control to the current container
  71367. * @param control defines the control to add
  71368. * @returns the current container
  71369. */
  71370. addControl(control: BABYLON.Nullable<Control>): Container;
  71371. /**
  71372. * Removes all controls from the current container
  71373. * @returns the current container
  71374. */
  71375. clearControls(): Container;
  71376. /**
  71377. * Removes a control from the current container
  71378. * @param control defines the control to remove
  71379. * @returns the current container
  71380. */
  71381. removeControl(control: Control): Container;
  71382. /** @hidden */
  71383. _reOrderControl(control: Control): void;
  71384. /** @hidden */
  71385. _offsetLeft(offset: number): void;
  71386. /** @hidden */
  71387. _offsetTop(offset: number): void;
  71388. /** @hidden */
  71389. _markAllAsDirty(): void;
  71390. /** @hidden */
  71391. protected _localDraw(context: CanvasRenderingContext2D): void;
  71392. /** @hidden */
  71393. _link(host: AdvancedDynamicTexture): void;
  71394. /** @hidden */
  71395. protected _beforeLayout(): void;
  71396. /** @hidden */
  71397. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71398. /** @hidden */
  71399. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71400. protected _postMeasure(): void;
  71401. /** @hidden */
  71402. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71403. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71404. /** @hidden */
  71405. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71406. /** @hidden */
  71407. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71408. /** Releases associated resources */
  71409. dispose(): void;
  71410. }
  71411. }
  71412. declare module BABYLON.GUI {
  71413. /** Class used to create rectangle container */
  71414. export class Rectangle extends Container {
  71415. name?: string | undefined;
  71416. private _thickness;
  71417. private _cornerRadius;
  71418. /** Gets or sets border thickness */
  71419. get thickness(): number;
  71420. set thickness(value: number);
  71421. /** Gets or sets the corner radius angle */
  71422. get cornerRadius(): number;
  71423. set cornerRadius(value: number);
  71424. /**
  71425. * Creates a new Rectangle
  71426. * @param name defines the control name
  71427. */
  71428. constructor(name?: string | undefined);
  71429. protected _getTypeName(): string;
  71430. protected _localDraw(context: CanvasRenderingContext2D): void;
  71431. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71432. private _drawRoundedRect;
  71433. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71434. }
  71435. }
  71436. declare module BABYLON.GUI {
  71437. /**
  71438. * Enum that determines the text-wrapping mode to use.
  71439. */
  71440. export enum TextWrapping {
  71441. /**
  71442. * Clip the text when it's larger than Control.width; this is the default mode.
  71443. */
  71444. Clip = 0,
  71445. /**
  71446. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71447. */
  71448. WordWrap = 1,
  71449. /**
  71450. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71451. */
  71452. Ellipsis = 2
  71453. }
  71454. /**
  71455. * Class used to create text block control
  71456. */
  71457. export class TextBlock extends Control {
  71458. /**
  71459. * Defines the name of the control
  71460. */
  71461. name?: string | undefined;
  71462. private _text;
  71463. private _textWrapping;
  71464. private _textHorizontalAlignment;
  71465. private _textVerticalAlignment;
  71466. private _lines;
  71467. private _resizeToFit;
  71468. private _lineSpacing;
  71469. private _outlineWidth;
  71470. private _outlineColor;
  71471. /**
  71472. * An event triggered after the text is changed
  71473. */
  71474. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71475. /**
  71476. * An event triggered after the text was broken up into lines
  71477. */
  71478. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71479. /**
  71480. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71481. */
  71482. get lines(): any[];
  71483. /**
  71484. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71485. */
  71486. get resizeToFit(): boolean;
  71487. /**
  71488. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71489. */
  71490. set resizeToFit(value: boolean);
  71491. /**
  71492. * Gets or sets a boolean indicating if text must be wrapped
  71493. */
  71494. get textWrapping(): TextWrapping | boolean;
  71495. /**
  71496. * Gets or sets a boolean indicating if text must be wrapped
  71497. */
  71498. set textWrapping(value: TextWrapping | boolean);
  71499. /**
  71500. * Gets or sets text to display
  71501. */
  71502. get text(): string;
  71503. /**
  71504. * Gets or sets text to display
  71505. */
  71506. set text(value: string);
  71507. /**
  71508. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71509. */
  71510. get textHorizontalAlignment(): number;
  71511. /**
  71512. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71513. */
  71514. set textHorizontalAlignment(value: number);
  71515. /**
  71516. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71517. */
  71518. get textVerticalAlignment(): number;
  71519. /**
  71520. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71521. */
  71522. set textVerticalAlignment(value: number);
  71523. /**
  71524. * Gets or sets line spacing value
  71525. */
  71526. set lineSpacing(value: string | number);
  71527. /**
  71528. * Gets or sets line spacing value
  71529. */
  71530. get lineSpacing(): string | number;
  71531. /**
  71532. * Gets or sets outlineWidth of the text to display
  71533. */
  71534. get outlineWidth(): number;
  71535. /**
  71536. * Gets or sets outlineWidth of the text to display
  71537. */
  71538. set outlineWidth(value: number);
  71539. /**
  71540. * Gets or sets outlineColor of the text to display
  71541. */
  71542. get outlineColor(): string;
  71543. /**
  71544. * Gets or sets outlineColor of the text to display
  71545. */
  71546. set outlineColor(value: string);
  71547. /**
  71548. * Creates a new TextBlock object
  71549. * @param name defines the name of the control
  71550. * @param text defines the text to display (emptry string by default)
  71551. */
  71552. constructor(
  71553. /**
  71554. * Defines the name of the control
  71555. */
  71556. name?: string | undefined, text?: string);
  71557. protected _getTypeName(): string;
  71558. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71559. private _drawText;
  71560. /** @hidden */
  71561. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71562. protected _applyStates(context: CanvasRenderingContext2D): void;
  71563. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71564. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71565. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71566. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71567. protected _renderLines(context: CanvasRenderingContext2D): void;
  71568. /**
  71569. * Given a width constraint applied on the text block, find the expected height
  71570. * @returns expected height
  71571. */
  71572. computeExpectedHeight(): number;
  71573. dispose(): void;
  71574. }
  71575. }
  71576. declare module BABYLON.GUI {
  71577. /**
  71578. * Class used to create 2D images
  71579. */
  71580. export class Image extends Control {
  71581. name?: string | undefined;
  71582. private _workingCanvas;
  71583. private _domImage;
  71584. private _imageWidth;
  71585. private _imageHeight;
  71586. private _loaded;
  71587. private _stretch;
  71588. private _source;
  71589. private _autoScale;
  71590. private _sourceLeft;
  71591. private _sourceTop;
  71592. private _sourceWidth;
  71593. private _sourceHeight;
  71594. private _svgAttributesComputationCompleted;
  71595. private _isSVG;
  71596. private _cellWidth;
  71597. private _cellHeight;
  71598. private _cellId;
  71599. private _populateNinePatchSlicesFromImage;
  71600. private _sliceLeft;
  71601. private _sliceRight;
  71602. private _sliceTop;
  71603. private _sliceBottom;
  71604. private _detectPointerOnOpaqueOnly;
  71605. /**
  71606. * BABYLON.Observable notified when the content is loaded
  71607. */
  71608. onImageLoadedObservable: BABYLON.Observable<Image>;
  71609. /**
  71610. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71611. */
  71612. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71613. /**
  71614. * Gets a boolean indicating that the content is loaded
  71615. */
  71616. get isLoaded(): boolean;
  71617. /**
  71618. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71619. */
  71620. get populateNinePatchSlicesFromImage(): boolean;
  71621. set populateNinePatchSlicesFromImage(value: boolean);
  71622. /**
  71623. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71624. * Beware using this as this will comsume more memory as the image has to be stored twice
  71625. */
  71626. get detectPointerOnOpaqueOnly(): boolean;
  71627. set detectPointerOnOpaqueOnly(value: boolean);
  71628. /**
  71629. * Gets or sets the left value for slicing (9-patch)
  71630. */
  71631. get sliceLeft(): number;
  71632. set sliceLeft(value: number);
  71633. /**
  71634. * Gets or sets the right value for slicing (9-patch)
  71635. */
  71636. get sliceRight(): number;
  71637. set sliceRight(value: number);
  71638. /**
  71639. * Gets or sets the top value for slicing (9-patch)
  71640. */
  71641. get sliceTop(): number;
  71642. set sliceTop(value: number);
  71643. /**
  71644. * Gets or sets the bottom value for slicing (9-patch)
  71645. */
  71646. get sliceBottom(): number;
  71647. set sliceBottom(value: number);
  71648. /**
  71649. * Gets or sets the left coordinate in the source image
  71650. */
  71651. get sourceLeft(): number;
  71652. set sourceLeft(value: number);
  71653. /**
  71654. * Gets or sets the top coordinate in the source image
  71655. */
  71656. get sourceTop(): number;
  71657. set sourceTop(value: number);
  71658. /**
  71659. * Gets or sets the width to capture in the source image
  71660. */
  71661. get sourceWidth(): number;
  71662. set sourceWidth(value: number);
  71663. /**
  71664. * Gets or sets the height to capture in the source image
  71665. */
  71666. get sourceHeight(): number;
  71667. set sourceHeight(value: number);
  71668. /** Indicates if the format of the image is SVG */
  71669. get isSVG(): boolean;
  71670. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71671. get svgAttributesComputationCompleted(): boolean;
  71672. /**
  71673. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71674. * @see http://doc.babylonjs.com/how_to/gui#image
  71675. */
  71676. get autoScale(): boolean;
  71677. set autoScale(value: boolean);
  71678. /** Gets or sets the streching mode used by the image */
  71679. get stretch(): number;
  71680. set stretch(value: number);
  71681. /** @hidden */
  71682. _rotate90(n: number, preserveProperties?: boolean): Image;
  71683. private _handleRotationForSVGImage;
  71684. private _rotate90SourceProperties;
  71685. /**
  71686. * Gets or sets the internal DOM image used to render the control
  71687. */
  71688. set domImage(value: HTMLImageElement);
  71689. get domImage(): HTMLImageElement;
  71690. private _onImageLoaded;
  71691. private _extractNinePatchSliceDataFromImage;
  71692. /**
  71693. * Gets or sets image source url
  71694. */
  71695. set source(value: BABYLON.Nullable<string>);
  71696. /**
  71697. * Checks for svg document with icon id present
  71698. */
  71699. private _svgCheck;
  71700. /**
  71701. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71702. * given external svg file and icon id
  71703. */
  71704. private _getSVGAttribs;
  71705. /**
  71706. * Gets or sets the cell width to use when animation sheet is enabled
  71707. * @see http://doc.babylonjs.com/how_to/gui#image
  71708. */
  71709. get cellWidth(): number;
  71710. set cellWidth(value: number);
  71711. /**
  71712. * Gets or sets the cell height to use when animation sheet is enabled
  71713. * @see http://doc.babylonjs.com/how_to/gui#image
  71714. */
  71715. get cellHeight(): number;
  71716. set cellHeight(value: number);
  71717. /**
  71718. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71719. * @see http://doc.babylonjs.com/how_to/gui#image
  71720. */
  71721. get cellId(): number;
  71722. set cellId(value: number);
  71723. /**
  71724. * Creates a new Image
  71725. * @param name defines the control name
  71726. * @param url defines the image url
  71727. */
  71728. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71729. /**
  71730. * Tests if a given coordinates belong to the current control
  71731. * @param x defines x coordinate to test
  71732. * @param y defines y coordinate to test
  71733. * @returns true if the coordinates are inside the control
  71734. */
  71735. contains(x: number, y: number): boolean;
  71736. protected _getTypeName(): string;
  71737. /** Force the control to synchronize with its content */
  71738. synchronizeSizeWithContent(): void;
  71739. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71740. private _prepareWorkingCanvasForOpaqueDetection;
  71741. private _drawImage;
  71742. _draw(context: CanvasRenderingContext2D): void;
  71743. private _renderCornerPatch;
  71744. private _renderNinePatch;
  71745. dispose(): void;
  71746. /** STRETCH_NONE */
  71747. static readonly STRETCH_NONE: number;
  71748. /** STRETCH_FILL */
  71749. static readonly STRETCH_FILL: number;
  71750. /** STRETCH_UNIFORM */
  71751. static readonly STRETCH_UNIFORM: number;
  71752. /** STRETCH_EXTEND */
  71753. static readonly STRETCH_EXTEND: number;
  71754. /** NINE_PATCH */
  71755. static readonly STRETCH_NINE_PATCH: number;
  71756. }
  71757. }
  71758. declare module BABYLON.GUI {
  71759. /**
  71760. * Class used to create 2D buttons
  71761. */
  71762. export class Button extends Rectangle {
  71763. name?: string | undefined;
  71764. /**
  71765. * Function called to generate a pointer enter animation
  71766. */
  71767. pointerEnterAnimation: () => void;
  71768. /**
  71769. * Function called to generate a pointer out animation
  71770. */
  71771. pointerOutAnimation: () => void;
  71772. /**
  71773. * Function called to generate a pointer down animation
  71774. */
  71775. pointerDownAnimation: () => void;
  71776. /**
  71777. * Function called to generate a pointer up animation
  71778. */
  71779. pointerUpAnimation: () => void;
  71780. /**
  71781. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71782. */
  71783. delegatePickingToChildren: boolean;
  71784. private _image;
  71785. /**
  71786. * Returns the image part of the button (if any)
  71787. */
  71788. get image(): BABYLON.Nullable<Image>;
  71789. private _textBlock;
  71790. /**
  71791. * Returns the image part of the button (if any)
  71792. */
  71793. get textBlock(): BABYLON.Nullable<TextBlock>;
  71794. /**
  71795. * Creates a new Button
  71796. * @param name defines the name of the button
  71797. */
  71798. constructor(name?: string | undefined);
  71799. protected _getTypeName(): string;
  71800. /** @hidden */
  71801. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71802. /** @hidden */
  71803. _onPointerEnter(target: Control): boolean;
  71804. /** @hidden */
  71805. _onPointerOut(target: Control, force?: boolean): void;
  71806. /** @hidden */
  71807. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71808. /** @hidden */
  71809. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71810. /**
  71811. * Creates a new button made with an image and a text
  71812. * @param name defines the name of the button
  71813. * @param text defines the text of the button
  71814. * @param imageUrl defines the url of the image
  71815. * @returns a new Button
  71816. */
  71817. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71818. /**
  71819. * Creates a new button made with an image
  71820. * @param name defines the name of the button
  71821. * @param imageUrl defines the url of the image
  71822. * @returns a new Button
  71823. */
  71824. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71825. /**
  71826. * Creates a new button made with a text
  71827. * @param name defines the name of the button
  71828. * @param text defines the text of the button
  71829. * @returns a new Button
  71830. */
  71831. static CreateSimpleButton(name: string, text: string): Button;
  71832. /**
  71833. * Creates a new button made with an image and a centered text
  71834. * @param name defines the name of the button
  71835. * @param text defines the text of the button
  71836. * @param imageUrl defines the url of the image
  71837. * @returns a new Button
  71838. */
  71839. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71840. }
  71841. }
  71842. declare module BABYLON.GUI {
  71843. /**
  71844. * Class used to create a 2D stack panel container
  71845. */
  71846. export class StackPanel extends Container {
  71847. name?: string | undefined;
  71848. private _isVertical;
  71849. private _manualWidth;
  71850. private _manualHeight;
  71851. private _doNotTrackManualChanges;
  71852. /**
  71853. * Gets or sets a boolean indicating that layou warnings should be ignored
  71854. */
  71855. ignoreLayoutWarnings: boolean;
  71856. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71857. get isVertical(): boolean;
  71858. set isVertical(value: boolean);
  71859. /**
  71860. * Gets or sets panel width.
  71861. * This value should not be set when in horizontal mode as it will be computed automatically
  71862. */
  71863. set width(value: string | number);
  71864. get width(): string | number;
  71865. /**
  71866. * Gets or sets panel height.
  71867. * This value should not be set when in vertical mode as it will be computed automatically
  71868. */
  71869. set height(value: string | number);
  71870. get height(): string | number;
  71871. /**
  71872. * Creates a new StackPanel
  71873. * @param name defines control name
  71874. */
  71875. constructor(name?: string | undefined);
  71876. protected _getTypeName(): string;
  71877. /** @hidden */
  71878. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71879. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71880. protected _postMeasure(): void;
  71881. }
  71882. }
  71883. declare module BABYLON.GUI {
  71884. /**
  71885. * Class used to represent a 2D checkbox
  71886. */
  71887. export class Checkbox extends Control {
  71888. name?: string | undefined;
  71889. private _isChecked;
  71890. private _background;
  71891. private _checkSizeRatio;
  71892. private _thickness;
  71893. /** Gets or sets border thickness */
  71894. get thickness(): number;
  71895. set thickness(value: number);
  71896. /**
  71897. * BABYLON.Observable raised when isChecked property changes
  71898. */
  71899. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71900. /** Gets or sets a value indicating the ratio between overall size and check size */
  71901. get checkSizeRatio(): number;
  71902. set checkSizeRatio(value: number);
  71903. /** Gets or sets background color */
  71904. get background(): string;
  71905. set background(value: string);
  71906. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71907. get isChecked(): boolean;
  71908. set isChecked(value: boolean);
  71909. /**
  71910. * Creates a new CheckBox
  71911. * @param name defines the control name
  71912. */
  71913. constructor(name?: string | undefined);
  71914. protected _getTypeName(): string;
  71915. /** @hidden */
  71916. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71917. /** @hidden */
  71918. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71919. /**
  71920. * Utility function to easily create a checkbox with a header
  71921. * @param title defines the label to use for the header
  71922. * @param onValueChanged defines the callback to call when value changes
  71923. * @returns a StackPanel containing the checkbox and a textBlock
  71924. */
  71925. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71926. }
  71927. }
  71928. declare module BABYLON.GUI {
  71929. /**
  71930. * Class used to store key control properties
  71931. */
  71932. export class KeyPropertySet {
  71933. /** Width */
  71934. width?: string;
  71935. /** Height */
  71936. height?: string;
  71937. /** Left padding */
  71938. paddingLeft?: string;
  71939. /** Right padding */
  71940. paddingRight?: string;
  71941. /** Top padding */
  71942. paddingTop?: string;
  71943. /** Bottom padding */
  71944. paddingBottom?: string;
  71945. /** Foreground color */
  71946. color?: string;
  71947. /** Background color */
  71948. background?: string;
  71949. }
  71950. /**
  71951. * Class used to create virtual keyboard
  71952. */
  71953. export class VirtualKeyboard extends StackPanel {
  71954. /** BABYLON.Observable raised when a key is pressed */
  71955. onKeyPressObservable: BABYLON.Observable<string>;
  71956. /** Gets or sets default key button width */
  71957. defaultButtonWidth: string;
  71958. /** Gets or sets default key button height */
  71959. defaultButtonHeight: string;
  71960. /** Gets or sets default key button left padding */
  71961. defaultButtonPaddingLeft: string;
  71962. /** Gets or sets default key button right padding */
  71963. defaultButtonPaddingRight: string;
  71964. /** Gets or sets default key button top padding */
  71965. defaultButtonPaddingTop: string;
  71966. /** Gets or sets default key button bottom padding */
  71967. defaultButtonPaddingBottom: string;
  71968. /** Gets or sets default key button foreground color */
  71969. defaultButtonColor: string;
  71970. /** Gets or sets default key button background color */
  71971. defaultButtonBackground: string;
  71972. /** Gets or sets shift button foreground color */
  71973. shiftButtonColor: string;
  71974. /** Gets or sets shift button thickness*/
  71975. selectedShiftThickness: number;
  71976. /** Gets shift key state */
  71977. shiftState: number;
  71978. protected _getTypeName(): string;
  71979. private _createKey;
  71980. /**
  71981. * Adds a new row of keys
  71982. * @param keys defines the list of keys to add
  71983. * @param propertySets defines the associated property sets
  71984. */
  71985. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71986. /**
  71987. * Set the shift key to a specific state
  71988. * @param shiftState defines the new shift state
  71989. */
  71990. applyShiftState(shiftState: number): void;
  71991. private _currentlyConnectedInputText;
  71992. private _connectedInputTexts;
  71993. private _onKeyPressObserver;
  71994. /** Gets the input text control currently attached to the keyboard */
  71995. get connectedInputText(): BABYLON.Nullable<InputText>;
  71996. /**
  71997. * Connects the keyboard with an input text control
  71998. *
  71999. * @param input defines the target control
  72000. */
  72001. connect(input: InputText): void;
  72002. /**
  72003. * Disconnects the keyboard from connected InputText controls
  72004. *
  72005. * @param input optionally defines a target control, otherwise all are disconnected
  72006. */
  72007. disconnect(input?: InputText): void;
  72008. private _removeConnectedInputObservables;
  72009. /**
  72010. * Release all resources
  72011. */
  72012. dispose(): void;
  72013. /**
  72014. * Creates a new keyboard using a default layout
  72015. *
  72016. * @param name defines control name
  72017. * @returns a new VirtualKeyboard
  72018. */
  72019. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  72020. }
  72021. }
  72022. declare module BABYLON.GUI {
  72023. /**
  72024. * Class used to create input text control
  72025. */
  72026. export class InputText extends Control implements IFocusableControl {
  72027. name?: string | undefined;
  72028. private _text;
  72029. private _placeholderText;
  72030. private _background;
  72031. private _focusedBackground;
  72032. private _focusedColor;
  72033. private _placeholderColor;
  72034. private _thickness;
  72035. private _margin;
  72036. private _autoStretchWidth;
  72037. private _maxWidth;
  72038. private _isFocused;
  72039. private _blinkTimeout;
  72040. private _blinkIsEven;
  72041. private _cursorOffset;
  72042. private _scrollLeft;
  72043. private _textWidth;
  72044. private _clickedCoordinate;
  72045. private _deadKey;
  72046. private _addKey;
  72047. private _currentKey;
  72048. private _isTextHighlightOn;
  72049. private _textHighlightColor;
  72050. private _highligherOpacity;
  72051. private _highlightedText;
  72052. private _startHighlightIndex;
  72053. private _endHighlightIndex;
  72054. private _cursorIndex;
  72055. private _onFocusSelectAll;
  72056. private _isPointerDown;
  72057. private _onClipboardObserver;
  72058. private _onPointerDblTapObserver;
  72059. /** @hidden */
  72060. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  72061. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  72062. promptMessage: string;
  72063. /** Force disable prompt on mobile device */
  72064. disableMobilePrompt: boolean;
  72065. /** BABYLON.Observable raised when the text changes */
  72066. onTextChangedObservable: BABYLON.Observable<InputText>;
  72067. /** BABYLON.Observable raised just before an entered character is to be added */
  72068. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  72069. /** BABYLON.Observable raised when the control gets the focus */
  72070. onFocusObservable: BABYLON.Observable<InputText>;
  72071. /** BABYLON.Observable raised when the control loses the focus */
  72072. onBlurObservable: BABYLON.Observable<InputText>;
  72073. /**Observable raised when the text is highlighted */
  72074. onTextHighlightObservable: BABYLON.Observable<InputText>;
  72075. /**Observable raised when copy event is triggered */
  72076. onTextCopyObservable: BABYLON.Observable<InputText>;
  72077. /** BABYLON.Observable raised when cut event is triggered */
  72078. onTextCutObservable: BABYLON.Observable<InputText>;
  72079. /** BABYLON.Observable raised when paste event is triggered */
  72080. onTextPasteObservable: BABYLON.Observable<InputText>;
  72081. /** BABYLON.Observable raised when a key event was processed */
  72082. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  72083. /** Gets or sets the maximum width allowed by the control */
  72084. get maxWidth(): string | number;
  72085. /** Gets the maximum width allowed by the control in pixels */
  72086. get maxWidthInPixels(): number;
  72087. set maxWidth(value: string | number);
  72088. /** Gets or sets the text highlighter transparency; default: 0.4 */
  72089. get highligherOpacity(): number;
  72090. set highligherOpacity(value: number);
  72091. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  72092. get onFocusSelectAll(): boolean;
  72093. set onFocusSelectAll(value: boolean);
  72094. /** Gets or sets the text hightlight color */
  72095. get textHighlightColor(): string;
  72096. set textHighlightColor(value: string);
  72097. /** Gets or sets control margin */
  72098. get margin(): string;
  72099. /** Gets control margin in pixels */
  72100. get marginInPixels(): number;
  72101. set margin(value: string);
  72102. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72103. get autoStretchWidth(): boolean;
  72104. set autoStretchWidth(value: boolean);
  72105. /** Gets or sets border thickness */
  72106. get thickness(): number;
  72107. set thickness(value: number);
  72108. /** Gets or sets the background color when focused */
  72109. get focusedBackground(): string;
  72110. set focusedBackground(value: string);
  72111. /** Gets or sets the background color when focused */
  72112. get focusedColor(): string;
  72113. set focusedColor(value: string);
  72114. /** Gets or sets the background color */
  72115. get background(): string;
  72116. set background(value: string);
  72117. /** Gets or sets the placeholder color */
  72118. get placeholderColor(): string;
  72119. set placeholderColor(value: string);
  72120. /** Gets or sets the text displayed when the control is empty */
  72121. get placeholderText(): string;
  72122. set placeholderText(value: string);
  72123. /** Gets or sets the dead key flag */
  72124. get deadKey(): boolean;
  72125. set deadKey(flag: boolean);
  72126. /** Gets or sets the highlight text */
  72127. get highlightedText(): string;
  72128. set highlightedText(text: string);
  72129. /** Gets or sets if the current key should be added */
  72130. get addKey(): boolean;
  72131. set addKey(flag: boolean);
  72132. /** Gets or sets the value of the current key being entered */
  72133. get currentKey(): string;
  72134. set currentKey(key: string);
  72135. /** Gets or sets the text displayed in the control */
  72136. get text(): string;
  72137. set text(value: string);
  72138. /** Gets or sets control width */
  72139. get width(): string | number;
  72140. set width(value: string | number);
  72141. /**
  72142. * Creates a new InputText
  72143. * @param name defines the control name
  72144. * @param text defines the text of the control
  72145. */
  72146. constructor(name?: string | undefined, text?: string);
  72147. /** @hidden */
  72148. onBlur(): void;
  72149. /** @hidden */
  72150. onFocus(): void;
  72151. protected _getTypeName(): string;
  72152. /**
  72153. * Function called to get the list of controls that should not steal the focus from this control
  72154. * @returns an array of controls
  72155. */
  72156. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72157. /** @hidden */
  72158. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72159. /** @hidden */
  72160. private _updateValueFromCursorIndex;
  72161. /** @hidden */
  72162. private _processDblClick;
  72163. /** @hidden */
  72164. private _selectAllText;
  72165. /**
  72166. * Handles the keyboard event
  72167. * @param evt Defines the KeyboardEvent
  72168. */
  72169. processKeyboard(evt: KeyboardEvent): void;
  72170. /** @hidden */
  72171. private _onCopyText;
  72172. /** @hidden */
  72173. private _onCutText;
  72174. /** @hidden */
  72175. private _onPasteText;
  72176. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72177. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72178. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72179. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72180. protected _beforeRenderText(text: string): string;
  72181. dispose(): void;
  72182. }
  72183. }
  72184. declare module BABYLON.GUI {
  72185. /**
  72186. * Class used to create a 2D grid container
  72187. */
  72188. export class Grid extends Container {
  72189. name?: string | undefined;
  72190. private _rowDefinitions;
  72191. private _columnDefinitions;
  72192. private _cells;
  72193. private _childControls;
  72194. /**
  72195. * Gets the number of columns
  72196. */
  72197. get columnCount(): number;
  72198. /**
  72199. * Gets the number of rows
  72200. */
  72201. get rowCount(): number;
  72202. /** Gets the list of children */
  72203. get children(): Control[];
  72204. /** Gets the list of cells (e.g. the containers) */
  72205. get cells(): {
  72206. [key: string]: Container;
  72207. };
  72208. /**
  72209. * Gets the definition of a specific row
  72210. * @param index defines the index of the row
  72211. * @returns the row definition
  72212. */
  72213. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72214. /**
  72215. * Gets the definition of a specific column
  72216. * @param index defines the index of the column
  72217. * @returns the column definition
  72218. */
  72219. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72220. /**
  72221. * Adds a new row to the grid
  72222. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72223. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72224. * @returns the current grid
  72225. */
  72226. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72227. /**
  72228. * Adds a new column to the grid
  72229. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72230. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72231. * @returns the current grid
  72232. */
  72233. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72234. /**
  72235. * Update a row definition
  72236. * @param index defines the index of the row to update
  72237. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72238. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72239. * @returns the current grid
  72240. */
  72241. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72242. /**
  72243. * Update a column definition
  72244. * @param index defines the index of the column to update
  72245. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72246. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72247. * @returns the current grid
  72248. */
  72249. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72250. /**
  72251. * Gets the list of children stored in a specific cell
  72252. * @param row defines the row to check
  72253. * @param column defines the column to check
  72254. * @returns the list of controls
  72255. */
  72256. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72257. /**
  72258. * Gets a string representing the child cell info (row x column)
  72259. * @param child defines the control to get info from
  72260. * @returns a string containing the child cell info (row x column)
  72261. */
  72262. getChildCellInfo(child: Control): string;
  72263. private _removeCell;
  72264. private _offsetCell;
  72265. /**
  72266. * Remove a column definition at specified index
  72267. * @param index defines the index of the column to remove
  72268. * @returns the current grid
  72269. */
  72270. removeColumnDefinition(index: number): Grid;
  72271. /**
  72272. * Remove a row definition at specified index
  72273. * @param index defines the index of the row to remove
  72274. * @returns the current grid
  72275. */
  72276. removeRowDefinition(index: number): Grid;
  72277. /**
  72278. * Adds a new control to the current grid
  72279. * @param control defines the control to add
  72280. * @param row defines the row where to add the control (0 by default)
  72281. * @param column defines the column where to add the control (0 by default)
  72282. * @returns the current grid
  72283. */
  72284. addControl(control: Control, row?: number, column?: number): Grid;
  72285. /**
  72286. * Removes a control from the current container
  72287. * @param control defines the control to remove
  72288. * @returns the current container
  72289. */
  72290. removeControl(control: Control): Container;
  72291. /**
  72292. * Creates a new Grid
  72293. * @param name defines control name
  72294. */
  72295. constructor(name?: string | undefined);
  72296. protected _getTypeName(): string;
  72297. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72298. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72299. _flagDescendantsAsMatrixDirty(): void;
  72300. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72301. /** Releases associated resources */
  72302. dispose(): void;
  72303. }
  72304. }
  72305. declare module BABYLON.GUI {
  72306. /** Class used to create color pickers */
  72307. export class ColorPicker extends Control {
  72308. name?: string | undefined;
  72309. private static _Epsilon;
  72310. private _colorWheelCanvas;
  72311. private _value;
  72312. private _tmpColor;
  72313. private _pointerStartedOnSquare;
  72314. private _pointerStartedOnWheel;
  72315. private _squareLeft;
  72316. private _squareTop;
  72317. private _squareSize;
  72318. private _h;
  72319. private _s;
  72320. private _v;
  72321. private _lastPointerDownID;
  72322. /**
  72323. * BABYLON.Observable raised when the value changes
  72324. */
  72325. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72326. /** Gets or sets the color of the color picker */
  72327. get value(): BABYLON.Color3;
  72328. set value(value: BABYLON.Color3);
  72329. /**
  72330. * Gets or sets control width
  72331. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72332. */
  72333. get width(): string | number;
  72334. set width(value: string | number);
  72335. /**
  72336. * Gets or sets control height
  72337. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72338. */
  72339. get height(): string | number;
  72340. /** Gets or sets control height */
  72341. set height(value: string | number);
  72342. /** Gets or sets control size */
  72343. get size(): string | number;
  72344. set size(value: string | number);
  72345. /**
  72346. * Creates a new ColorPicker
  72347. * @param name defines the control name
  72348. */
  72349. constructor(name?: string | undefined);
  72350. protected _getTypeName(): string;
  72351. /** @hidden */
  72352. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72353. private _updateSquareProps;
  72354. private _drawGradientSquare;
  72355. private _drawCircle;
  72356. private _createColorWheelCanvas;
  72357. /** @hidden */
  72358. _draw(context: CanvasRenderingContext2D): void;
  72359. private _pointerIsDown;
  72360. private _updateValueFromPointer;
  72361. private _isPointOnSquare;
  72362. private _isPointOnWheel;
  72363. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72364. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72365. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72366. /**
  72367. * This function expands the color picker by creating a color picker dialog with manual
  72368. * color value input and the ability to save colors into an array to be used later in
  72369. * subsequent launches of the dialogue.
  72370. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72371. * @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.
  72372. * @returns picked color as a hex string and the saved colors array as hex strings.
  72373. */
  72374. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72375. pickerWidth?: string;
  72376. pickerHeight?: string;
  72377. headerHeight?: string;
  72378. lastColor?: string;
  72379. swatchLimit?: number;
  72380. numSwatchesPerLine?: number;
  72381. savedColors?: Array<string>;
  72382. }): Promise<{
  72383. savedColors?: string[];
  72384. pickedColor: string;
  72385. }>;
  72386. }
  72387. }
  72388. declare module BABYLON.GUI {
  72389. /** Class used to create 2D ellipse containers */
  72390. export class Ellipse extends Container {
  72391. name?: string | undefined;
  72392. private _thickness;
  72393. /** Gets or sets border thickness */
  72394. get thickness(): number;
  72395. set thickness(value: number);
  72396. /**
  72397. * Creates a new Ellipse
  72398. * @param name defines the control name
  72399. */
  72400. constructor(name?: string | undefined);
  72401. protected _getTypeName(): string;
  72402. protected _localDraw(context: CanvasRenderingContext2D): void;
  72403. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72404. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72405. }
  72406. }
  72407. declare module BABYLON.GUI {
  72408. /**
  72409. * Class used to create a password control
  72410. */
  72411. export class InputPassword extends InputText {
  72412. protected _beforeRenderText(text: string): string;
  72413. }
  72414. }
  72415. declare module BABYLON.GUI {
  72416. /** Class used to render 2D lines */
  72417. export class Line extends Control {
  72418. name?: string | undefined;
  72419. private _lineWidth;
  72420. private _x1;
  72421. private _y1;
  72422. private _x2;
  72423. private _y2;
  72424. private _dash;
  72425. private _connectedControl;
  72426. private _connectedControlDirtyObserver;
  72427. /** Gets or sets the dash pattern */
  72428. get dash(): Array<number>;
  72429. set dash(value: Array<number>);
  72430. /** Gets or sets the control connected with the line end */
  72431. get connectedControl(): Control;
  72432. set connectedControl(value: Control);
  72433. /** Gets or sets start coordinates on X axis */
  72434. get x1(): string | number;
  72435. set x1(value: string | number);
  72436. /** Gets or sets start coordinates on Y axis */
  72437. get y1(): string | number;
  72438. set y1(value: string | number);
  72439. /** Gets or sets end coordinates on X axis */
  72440. get x2(): string | number;
  72441. set x2(value: string | number);
  72442. /** Gets or sets end coordinates on Y axis */
  72443. get y2(): string | number;
  72444. set y2(value: string | number);
  72445. /** Gets or sets line width */
  72446. get lineWidth(): number;
  72447. set lineWidth(value: number);
  72448. /** Gets or sets horizontal alignment */
  72449. set horizontalAlignment(value: number);
  72450. /** Gets or sets vertical alignment */
  72451. set verticalAlignment(value: number);
  72452. private get _effectiveX2();
  72453. private get _effectiveY2();
  72454. /**
  72455. * Creates a new Line
  72456. * @param name defines the control name
  72457. */
  72458. constructor(name?: string | undefined);
  72459. protected _getTypeName(): string;
  72460. _draw(context: CanvasRenderingContext2D): void;
  72461. _measure(): void;
  72462. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72463. /**
  72464. * Move one end of the line given 3D cartesian coordinates.
  72465. * @param position Targeted world position
  72466. * @param scene BABYLON.Scene
  72467. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72468. */
  72469. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72470. /**
  72471. * Move one end of the line to a position in screen absolute space.
  72472. * @param projectedPosition Position in screen absolute space (X, Y)
  72473. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72474. */
  72475. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72476. }
  72477. }
  72478. declare module BABYLON.GUI {
  72479. /**
  72480. * Class used to store a point for a MultiLine object.
  72481. * The point can be pure 2D coordinates, a mesh or a control
  72482. */
  72483. export class MultiLinePoint {
  72484. private _multiLine;
  72485. private _x;
  72486. private _y;
  72487. private _control;
  72488. private _mesh;
  72489. private _controlObserver;
  72490. private _meshObserver;
  72491. /** @hidden */
  72492. _point: BABYLON.Vector2;
  72493. /**
  72494. * Creates a new MultiLinePoint
  72495. * @param multiLine defines the source MultiLine object
  72496. */
  72497. constructor(multiLine: MultiLine);
  72498. /** Gets or sets x coordinate */
  72499. get x(): string | number;
  72500. set x(value: string | number);
  72501. /** Gets or sets y coordinate */
  72502. get y(): string | number;
  72503. set y(value: string | number);
  72504. /** Gets or sets the control associated with this point */
  72505. get control(): BABYLON.Nullable<Control>;
  72506. set control(value: BABYLON.Nullable<Control>);
  72507. /** Gets or sets the mesh associated with this point */
  72508. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72509. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72510. /** Resets links */
  72511. resetLinks(): void;
  72512. /**
  72513. * Gets a translation vector
  72514. * @returns the translation vector
  72515. */
  72516. translate(): BABYLON.Vector2;
  72517. private _translatePoint;
  72518. /** Release associated resources */
  72519. dispose(): void;
  72520. }
  72521. }
  72522. declare module BABYLON.GUI {
  72523. /**
  72524. * Class used to create multi line control
  72525. */
  72526. export class MultiLine extends Control {
  72527. name?: string | undefined;
  72528. private _lineWidth;
  72529. private _dash;
  72530. private _points;
  72531. private _minX;
  72532. private _minY;
  72533. private _maxX;
  72534. private _maxY;
  72535. /**
  72536. * Creates a new MultiLine
  72537. * @param name defines the control name
  72538. */
  72539. constructor(name?: string | undefined);
  72540. /** Gets or sets dash pattern */
  72541. get dash(): Array<number>;
  72542. set dash(value: Array<number>);
  72543. /**
  72544. * Gets point stored at specified index
  72545. * @param index defines the index to look for
  72546. * @returns the requested point if found
  72547. */
  72548. getAt(index: number): MultiLinePoint;
  72549. /** Function called when a point is updated */
  72550. onPointUpdate: () => void;
  72551. /**
  72552. * Adds new points to the point collection
  72553. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72554. * @returns the list of created MultiLinePoint
  72555. */
  72556. add(...items: (AbstractMesh | Control | {
  72557. x: string | number;
  72558. y: string | number;
  72559. })[]): MultiLinePoint[];
  72560. /**
  72561. * Adds a new point to the point collection
  72562. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72563. * @returns the created MultiLinePoint
  72564. */
  72565. push(item?: (AbstractMesh | Control | {
  72566. x: string | number;
  72567. y: string | number;
  72568. })): MultiLinePoint;
  72569. /**
  72570. * Remove a specific value or point from the active point collection
  72571. * @param value defines the value or point to remove
  72572. */
  72573. remove(value: number | MultiLinePoint): void;
  72574. /**
  72575. * Resets this object to initial state (no point)
  72576. */
  72577. reset(): void;
  72578. /**
  72579. * Resets all links
  72580. */
  72581. resetLinks(): void;
  72582. /** Gets or sets line width */
  72583. get lineWidth(): number;
  72584. set lineWidth(value: number);
  72585. set horizontalAlignment(value: number);
  72586. set verticalAlignment(value: number);
  72587. protected _getTypeName(): string;
  72588. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72589. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72590. _measure(): void;
  72591. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72592. dispose(): void;
  72593. }
  72594. }
  72595. declare module BABYLON.GUI {
  72596. /**
  72597. * Class used to create radio button controls
  72598. */
  72599. export class RadioButton extends Control {
  72600. name?: string | undefined;
  72601. private _isChecked;
  72602. private _background;
  72603. private _checkSizeRatio;
  72604. private _thickness;
  72605. /** Gets or sets border thickness */
  72606. get thickness(): number;
  72607. set thickness(value: number);
  72608. /** Gets or sets group name */
  72609. group: string;
  72610. /** BABYLON.Observable raised when isChecked is changed */
  72611. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72612. /** Gets or sets a value indicating the ratio between overall size and check size */
  72613. get checkSizeRatio(): number;
  72614. set checkSizeRatio(value: number);
  72615. /** Gets or sets background color */
  72616. get background(): string;
  72617. set background(value: string);
  72618. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72619. get isChecked(): boolean;
  72620. set isChecked(value: boolean);
  72621. /**
  72622. * Creates a new RadioButton
  72623. * @param name defines the control name
  72624. */
  72625. constructor(name?: string | undefined);
  72626. protected _getTypeName(): string;
  72627. _draw(context: CanvasRenderingContext2D): void;
  72628. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72629. /**
  72630. * Utility function to easily create a radio button with a header
  72631. * @param title defines the label to use for the header
  72632. * @param group defines the group to use for the radio button
  72633. * @param isChecked defines the initial state of the radio button
  72634. * @param onValueChanged defines the callback to call when value changes
  72635. * @returns a StackPanel containing the radio button and a textBlock
  72636. */
  72637. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72638. }
  72639. }
  72640. declare module BABYLON.GUI {
  72641. /**
  72642. * Class used to create slider controls
  72643. */
  72644. export class BaseSlider extends Control {
  72645. name?: string | undefined;
  72646. protected _thumbWidth: ValueAndUnit;
  72647. private _minimum;
  72648. private _maximum;
  72649. private _value;
  72650. private _isVertical;
  72651. protected _barOffset: ValueAndUnit;
  72652. private _isThumbClamped;
  72653. protected _displayThumb: boolean;
  72654. private _step;
  72655. private _lastPointerDownID;
  72656. protected _effectiveBarOffset: number;
  72657. protected _renderLeft: number;
  72658. protected _renderTop: number;
  72659. protected _renderWidth: number;
  72660. protected _renderHeight: number;
  72661. protected _backgroundBoxLength: number;
  72662. protected _backgroundBoxThickness: number;
  72663. protected _effectiveThumbThickness: number;
  72664. /** BABYLON.Observable raised when the sldier value changes */
  72665. onValueChangedObservable: BABYLON.Observable<number>;
  72666. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72667. get displayThumb(): boolean;
  72668. set displayThumb(value: boolean);
  72669. /** Gets or sets a step to apply to values (0 by default) */
  72670. get step(): number;
  72671. set step(value: number);
  72672. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72673. get barOffset(): string | number;
  72674. /** Gets main bar offset in pixels*/
  72675. get barOffsetInPixels(): number;
  72676. set barOffset(value: string | number);
  72677. /** Gets or sets thumb width */
  72678. get thumbWidth(): string | number;
  72679. /** Gets thumb width in pixels */
  72680. get thumbWidthInPixels(): number;
  72681. set thumbWidth(value: string | number);
  72682. /** Gets or sets minimum value */
  72683. get minimum(): number;
  72684. set minimum(value: number);
  72685. /** Gets or sets maximum value */
  72686. get maximum(): number;
  72687. set maximum(value: number);
  72688. /** Gets or sets current value */
  72689. get value(): number;
  72690. set value(value: number);
  72691. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72692. get isVertical(): boolean;
  72693. set isVertical(value: boolean);
  72694. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72695. get isThumbClamped(): boolean;
  72696. set isThumbClamped(value: boolean);
  72697. /**
  72698. * Creates a new BaseSlider
  72699. * @param name defines the control name
  72700. */
  72701. constructor(name?: string | undefined);
  72702. protected _getTypeName(): string;
  72703. protected _getThumbPosition(): number;
  72704. protected _getThumbThickness(type: string): number;
  72705. protected _prepareRenderingData(type: string): void;
  72706. private _pointerIsDown;
  72707. /** @hidden */
  72708. protected _updateValueFromPointer(x: number, y: number): void;
  72709. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72710. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72711. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72712. }
  72713. }
  72714. declare module BABYLON.GUI {
  72715. /**
  72716. * Class used to create slider controls
  72717. */
  72718. export class Slider extends BaseSlider {
  72719. name?: string | undefined;
  72720. private _background;
  72721. private _borderColor;
  72722. private _isThumbCircle;
  72723. protected _displayValueBar: boolean;
  72724. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72725. get displayValueBar(): boolean;
  72726. set displayValueBar(value: boolean);
  72727. /** Gets or sets border color */
  72728. get borderColor(): string;
  72729. set borderColor(value: string);
  72730. /** Gets or sets background color */
  72731. get background(): string;
  72732. set background(value: string);
  72733. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72734. get isThumbCircle(): boolean;
  72735. set isThumbCircle(value: boolean);
  72736. /**
  72737. * Creates a new Slider
  72738. * @param name defines the control name
  72739. */
  72740. constructor(name?: string | undefined);
  72741. protected _getTypeName(): string;
  72742. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72743. }
  72744. }
  72745. declare module BABYLON.GUI {
  72746. /** Class used to create a RadioGroup
  72747. * which contains groups of radio buttons
  72748. */
  72749. export class SelectorGroup {
  72750. /** name of SelectorGroup */
  72751. name: string;
  72752. private _groupPanel;
  72753. private _selectors;
  72754. private _groupHeader;
  72755. /**
  72756. * Creates a new SelectorGroup
  72757. * @param name of group, used as a group heading
  72758. */
  72759. constructor(
  72760. /** name of SelectorGroup */
  72761. name: string);
  72762. /** Gets the groupPanel of the SelectorGroup */
  72763. get groupPanel(): StackPanel;
  72764. /** Gets the selectors array */
  72765. get selectors(): StackPanel[];
  72766. /** Gets and sets the group header */
  72767. get header(): string;
  72768. set header(label: string);
  72769. /** @hidden */
  72770. private _addGroupHeader;
  72771. /** @hidden*/
  72772. _getSelector(selectorNb: number): StackPanel | undefined;
  72773. /** Removes the selector at the given position
  72774. * @param selectorNb the position of the selector within the group
  72775. */
  72776. removeSelector(selectorNb: number): void;
  72777. }
  72778. /** Class used to create a CheckboxGroup
  72779. * which contains groups of checkbox buttons
  72780. */
  72781. export class CheckboxGroup extends SelectorGroup {
  72782. /** Adds a checkbox as a control
  72783. * @param text is the label for the selector
  72784. * @param func is the function called when the Selector is checked
  72785. * @param checked is true when Selector is checked
  72786. */
  72787. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72788. /** @hidden */
  72789. _setSelectorLabel(selectorNb: number, label: string): void;
  72790. /** @hidden */
  72791. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72792. /** @hidden */
  72793. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72794. /** @hidden */
  72795. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72796. }
  72797. /** Class used to create a RadioGroup
  72798. * which contains groups of radio buttons
  72799. */
  72800. export class RadioGroup extends SelectorGroup {
  72801. private _selectNb;
  72802. /** Adds a radio button as a control
  72803. * @param label is the label for the selector
  72804. * @param func is the function called when the Selector is checked
  72805. * @param checked is true when Selector is checked
  72806. */
  72807. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72808. /** @hidden */
  72809. _setSelectorLabel(selectorNb: number, label: string): void;
  72810. /** @hidden */
  72811. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72812. /** @hidden */
  72813. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72814. /** @hidden */
  72815. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72816. }
  72817. /** Class used to create a SliderGroup
  72818. * which contains groups of slider buttons
  72819. */
  72820. export class SliderGroup extends SelectorGroup {
  72821. /**
  72822. * Adds a slider to the SelectorGroup
  72823. * @param label is the label for the SliderBar
  72824. * @param func is the function called when the Slider moves
  72825. * @param unit is a string describing the units used, eg degrees or metres
  72826. * @param min is the minimum value for the Slider
  72827. * @param max is the maximum value for the Slider
  72828. * @param value is the start value for the Slider between min and max
  72829. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72830. */
  72831. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72832. /** @hidden */
  72833. _setSelectorLabel(selectorNb: number, label: string): void;
  72834. /** @hidden */
  72835. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72836. /** @hidden */
  72837. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72838. /** @hidden */
  72839. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72840. }
  72841. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72842. * @see http://doc.babylonjs.com/how_to/selector
  72843. */
  72844. export class SelectionPanel extends Rectangle {
  72845. /** name of SelectionPanel */
  72846. name: string;
  72847. /** an array of SelectionGroups */
  72848. groups: SelectorGroup[];
  72849. private _panel;
  72850. private _buttonColor;
  72851. private _buttonBackground;
  72852. private _headerColor;
  72853. private _barColor;
  72854. private _barHeight;
  72855. private _spacerHeight;
  72856. private _labelColor;
  72857. private _groups;
  72858. private _bars;
  72859. /**
  72860. * Creates a new SelectionPanel
  72861. * @param name of SelectionPanel
  72862. * @param groups is an array of SelectionGroups
  72863. */
  72864. constructor(
  72865. /** name of SelectionPanel */
  72866. name: string,
  72867. /** an array of SelectionGroups */
  72868. groups?: SelectorGroup[]);
  72869. protected _getTypeName(): string;
  72870. /** Gets or sets the headerColor */
  72871. get headerColor(): string;
  72872. set headerColor(color: string);
  72873. private _setHeaderColor;
  72874. /** Gets or sets the button color */
  72875. get buttonColor(): string;
  72876. set buttonColor(color: string);
  72877. private _setbuttonColor;
  72878. /** Gets or sets the label color */
  72879. get labelColor(): string;
  72880. set labelColor(color: string);
  72881. private _setLabelColor;
  72882. /** Gets or sets the button background */
  72883. get buttonBackground(): string;
  72884. set buttonBackground(color: string);
  72885. private _setButtonBackground;
  72886. /** Gets or sets the color of separator bar */
  72887. get barColor(): string;
  72888. set barColor(color: string);
  72889. private _setBarColor;
  72890. /** Gets or sets the height of separator bar */
  72891. get barHeight(): string;
  72892. set barHeight(value: string);
  72893. private _setBarHeight;
  72894. /** Gets or sets the height of spacers*/
  72895. get spacerHeight(): string;
  72896. set spacerHeight(value: string);
  72897. private _setSpacerHeight;
  72898. /** Adds a bar between groups */
  72899. private _addSpacer;
  72900. /** Add a group to the selection panel
  72901. * @param group is the selector group to add
  72902. */
  72903. addGroup(group: SelectorGroup): void;
  72904. /** Remove the group from the given position
  72905. * @param groupNb is the position of the group in the list
  72906. */
  72907. removeGroup(groupNb: number): void;
  72908. /** Change a group header label
  72909. * @param label is the new group header label
  72910. * @param groupNb is the number of the group to relabel
  72911. * */
  72912. setHeaderName(label: string, groupNb: number): void;
  72913. /** Change selector label to the one given
  72914. * @param label is the new selector label
  72915. * @param groupNb is the number of the groupcontaining the selector
  72916. * @param selectorNb is the number of the selector within a group to relabel
  72917. * */
  72918. relabel(label: string, groupNb: number, selectorNb: number): void;
  72919. /** For a given group position remove the selector at the given position
  72920. * @param groupNb is the number of the group to remove the selector from
  72921. * @param selectorNb is the number of the selector within the group
  72922. */
  72923. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72924. /** For a given group position of correct type add a checkbox button
  72925. * @param groupNb is the number of the group to remove the selector from
  72926. * @param label is the label for the selector
  72927. * @param func is the function called when the Selector is checked
  72928. * @param checked is true when Selector is checked
  72929. */
  72930. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72931. /** For a given group position of correct type add a radio button
  72932. * @param groupNb is the number of the group to remove the selector from
  72933. * @param label is the label for the selector
  72934. * @param func is the function called when the Selector is checked
  72935. * @param checked is true when Selector is checked
  72936. */
  72937. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72938. /**
  72939. * For a given slider group add a slider
  72940. * @param groupNb is the number of the group to add the slider to
  72941. * @param label is the label for the Slider
  72942. * @param func is the function called when the Slider moves
  72943. * @param unit is a string describing the units used, eg degrees or metres
  72944. * @param min is the minimum value for the Slider
  72945. * @param max is the maximum value for the Slider
  72946. * @param value is the start value for the Slider between min and max
  72947. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72948. */
  72949. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72950. }
  72951. }
  72952. declare module BABYLON.GUI {
  72953. /**
  72954. * Class used to hold a the container for ScrollViewer
  72955. * @hidden
  72956. */
  72957. export class _ScrollViewerWindow extends Container {
  72958. parentClientWidth: number;
  72959. parentClientHeight: number;
  72960. private _freezeControls;
  72961. private _parentMeasure;
  72962. private _oldLeft;
  72963. private _oldTop;
  72964. get freezeControls(): boolean;
  72965. set freezeControls(value: boolean);
  72966. private _bucketWidth;
  72967. private _bucketHeight;
  72968. private _buckets;
  72969. private _bucketLen;
  72970. get bucketWidth(): number;
  72971. get bucketHeight(): number;
  72972. setBucketSizes(width: number, height: number): void;
  72973. private _useBuckets;
  72974. private _makeBuckets;
  72975. private _dispatchInBuckets;
  72976. private _updateMeasures;
  72977. private _updateChildrenMeasures;
  72978. /**
  72979. * Creates a new ScrollViewerWindow
  72980. * @param name of ScrollViewerWindow
  72981. */
  72982. constructor(name?: string);
  72983. protected _getTypeName(): string;
  72984. /** @hidden */
  72985. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72986. /** @hidden */
  72987. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72988. private _scrollChildren;
  72989. private _scrollChildrenWithBuckets;
  72990. /** @hidden */
  72991. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72992. protected _postMeasure(): void;
  72993. }
  72994. }
  72995. declare module BABYLON.GUI {
  72996. /**
  72997. * Class used to create slider controls
  72998. */
  72999. export class ScrollBar extends BaseSlider {
  73000. name?: string | undefined;
  73001. private _background;
  73002. private _borderColor;
  73003. private _tempMeasure;
  73004. /** Gets or sets border color */
  73005. get borderColor(): string;
  73006. set borderColor(value: string);
  73007. /** Gets or sets background color */
  73008. get background(): string;
  73009. set background(value: string);
  73010. /**
  73011. * Creates a new Slider
  73012. * @param name defines the control name
  73013. */
  73014. constructor(name?: string | undefined);
  73015. protected _getTypeName(): string;
  73016. protected _getThumbThickness(): number;
  73017. _draw(context: CanvasRenderingContext2D): void;
  73018. private _first;
  73019. private _originX;
  73020. private _originY;
  73021. /** @hidden */
  73022. protected _updateValueFromPointer(x: number, y: number): void;
  73023. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73024. }
  73025. }
  73026. declare module BABYLON.GUI {
  73027. /**
  73028. * Class used to create slider controls
  73029. */
  73030. export class ImageScrollBar extends BaseSlider {
  73031. name?: string | undefined;
  73032. private _backgroundBaseImage;
  73033. private _backgroundImage;
  73034. private _thumbImage;
  73035. private _thumbBaseImage;
  73036. private _thumbLength;
  73037. private _thumbHeight;
  73038. private _barImageHeight;
  73039. private _tempMeasure;
  73040. /** Number of 90° rotation to apply on the images when in vertical mode */
  73041. num90RotationInVerticalMode: number;
  73042. /**
  73043. * Gets or sets the image used to render the background for horizontal bar
  73044. */
  73045. get backgroundImage(): Image;
  73046. set backgroundImage(value: Image);
  73047. /**
  73048. * Gets or sets the image used to render the thumb
  73049. */
  73050. get thumbImage(): Image;
  73051. set thumbImage(value: Image);
  73052. /**
  73053. * Gets or sets the length of the thumb
  73054. */
  73055. get thumbLength(): number;
  73056. set thumbLength(value: number);
  73057. /**
  73058. * Gets or sets the height of the thumb
  73059. */
  73060. get thumbHeight(): number;
  73061. set thumbHeight(value: number);
  73062. /**
  73063. * Gets or sets the height of the bar image
  73064. */
  73065. get barImageHeight(): number;
  73066. set barImageHeight(value: number);
  73067. /**
  73068. * Creates a new ImageScrollBar
  73069. * @param name defines the control name
  73070. */
  73071. constructor(name?: string | undefined);
  73072. protected _getTypeName(): string;
  73073. protected _getThumbThickness(): number;
  73074. _draw(context: CanvasRenderingContext2D): void;
  73075. private _first;
  73076. private _originX;
  73077. private _originY;
  73078. /** @hidden */
  73079. protected _updateValueFromPointer(x: number, y: number): void;
  73080. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  73081. }
  73082. }
  73083. declare module BABYLON.GUI {
  73084. /**
  73085. * Class used to hold a viewer window and sliders in a grid
  73086. */
  73087. export class ScrollViewer extends Rectangle {
  73088. private _grid;
  73089. private _horizontalBarSpace;
  73090. private _verticalBarSpace;
  73091. private _dragSpace;
  73092. private _horizontalBar;
  73093. private _verticalBar;
  73094. private _barColor;
  73095. private _barBackground;
  73096. private _barImage;
  73097. private _horizontalBarImage;
  73098. private _verticalBarImage;
  73099. private _barBackgroundImage;
  73100. private _horizontalBarBackgroundImage;
  73101. private _verticalBarBackgroundImage;
  73102. private _barSize;
  73103. private _window;
  73104. private _pointerIsOver;
  73105. private _wheelPrecision;
  73106. private _onPointerObserver;
  73107. private _clientWidth;
  73108. private _clientHeight;
  73109. private _useImageBar;
  73110. private _thumbLength;
  73111. private _thumbHeight;
  73112. private _barImageHeight;
  73113. private _horizontalBarImageHeight;
  73114. private _verticalBarImageHeight;
  73115. /**
  73116. * Gets the horizontal scrollbar
  73117. */
  73118. get horizontalBar(): ScrollBar | ImageScrollBar;
  73119. /**
  73120. * Gets the vertical scrollbar
  73121. */
  73122. get verticalBar(): ScrollBar | ImageScrollBar;
  73123. /**
  73124. * Adds a new control to the current container
  73125. * @param control defines the control to add
  73126. * @returns the current container
  73127. */
  73128. addControl(control: BABYLON.Nullable<Control>): Container;
  73129. /**
  73130. * Removes a control from the current container
  73131. * @param control defines the control to remove
  73132. * @returns the current container
  73133. */
  73134. removeControl(control: Control): Container;
  73135. /** Gets the list of children */
  73136. get children(): Control[];
  73137. _flagDescendantsAsMatrixDirty(): void;
  73138. /**
  73139. * Freezes or unfreezes the controls in the window.
  73140. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73141. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73142. */
  73143. get freezeControls(): boolean;
  73144. set freezeControls(value: boolean);
  73145. /** Gets the bucket width */
  73146. get bucketWidth(): number;
  73147. /** Gets the bucket height */
  73148. get bucketHeight(): number;
  73149. /**
  73150. * Sets the bucket sizes.
  73151. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73152. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73153. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73154. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73155. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73156. * used), that's why it is not enabled by default.
  73157. * @param width width of the bucket
  73158. * @param height height of the bucket
  73159. */
  73160. setBucketSizes(width: number, height: number): void;
  73161. private _forceHorizontalBar;
  73162. private _forceVerticalBar;
  73163. /**
  73164. * Forces the horizontal scroll bar to be displayed
  73165. */
  73166. get forceHorizontalBar(): boolean;
  73167. set forceHorizontalBar(value: boolean);
  73168. /**
  73169. * Forces the vertical scroll bar to be displayed
  73170. */
  73171. get forceVerticalBar(): boolean;
  73172. set forceVerticalBar(value: boolean);
  73173. /**
  73174. * Creates a new ScrollViewer
  73175. * @param name of ScrollViewer
  73176. */
  73177. constructor(name?: string, isImageBased?: boolean);
  73178. /** Reset the scroll viewer window to initial size */
  73179. resetWindow(): void;
  73180. protected _getTypeName(): string;
  73181. private _buildClientSizes;
  73182. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73183. protected _postMeasure(): void;
  73184. /**
  73185. * Gets or sets the mouse wheel precision
  73186. * from 0 to 1 with a default value of 0.05
  73187. * */
  73188. get wheelPrecision(): number;
  73189. set wheelPrecision(value: number);
  73190. /** Gets or sets the scroll bar container background color */
  73191. get scrollBackground(): string;
  73192. set scrollBackground(color: string);
  73193. /** Gets or sets the bar color */
  73194. get barColor(): string;
  73195. set barColor(color: string);
  73196. /** Gets or sets the bar image */
  73197. get thumbImage(): Image;
  73198. set thumbImage(value: Image);
  73199. /** Gets or sets the horizontal bar image */
  73200. get horizontalThumbImage(): Image;
  73201. set horizontalThumbImage(value: Image);
  73202. /** Gets or sets the vertical bar image */
  73203. get verticalThumbImage(): Image;
  73204. set verticalThumbImage(value: Image);
  73205. /** Gets or sets the size of the bar */
  73206. get barSize(): number;
  73207. set barSize(value: number);
  73208. /** Gets or sets the length of the thumb */
  73209. get thumbLength(): number;
  73210. set thumbLength(value: number);
  73211. /** Gets or sets the height of the thumb */
  73212. get thumbHeight(): number;
  73213. set thumbHeight(value: number);
  73214. /** Gets or sets the height of the bar image */
  73215. get barImageHeight(): number;
  73216. set barImageHeight(value: number);
  73217. /** Gets or sets the height of the horizontal bar image */
  73218. get horizontalBarImageHeight(): number;
  73219. set horizontalBarImageHeight(value: number);
  73220. /** Gets or sets the height of the vertical bar image */
  73221. get verticalBarImageHeight(): number;
  73222. set verticalBarImageHeight(value: number);
  73223. /** Gets or sets the bar background */
  73224. get barBackground(): string;
  73225. set barBackground(color: string);
  73226. /** Gets or sets the bar background image */
  73227. get barImage(): Image;
  73228. set barImage(value: Image);
  73229. /** Gets or sets the horizontal bar background image */
  73230. get horizontalBarImage(): Image;
  73231. set horizontalBarImage(value: Image);
  73232. /** Gets or sets the vertical bar background image */
  73233. get verticalBarImage(): Image;
  73234. set verticalBarImage(value: Image);
  73235. private _setWindowPosition;
  73236. /** @hidden */
  73237. private _updateScroller;
  73238. _link(host: AdvancedDynamicTexture): void;
  73239. /** @hidden */
  73240. private _addBar;
  73241. /** @hidden */
  73242. private _attachWheel;
  73243. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73244. /** Releases associated resources */
  73245. dispose(): void;
  73246. }
  73247. }
  73248. declare module BABYLON.GUI {
  73249. /** Class used to render a grid */
  73250. export class DisplayGrid extends Control {
  73251. name?: string | undefined;
  73252. private _cellWidth;
  73253. private _cellHeight;
  73254. private _minorLineTickness;
  73255. private _minorLineColor;
  73256. private _majorLineTickness;
  73257. private _majorLineColor;
  73258. private _majorLineFrequency;
  73259. private _background;
  73260. private _displayMajorLines;
  73261. private _displayMinorLines;
  73262. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73263. get displayMinorLines(): boolean;
  73264. set displayMinorLines(value: boolean);
  73265. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73266. get displayMajorLines(): boolean;
  73267. set displayMajorLines(value: boolean);
  73268. /** Gets or sets background color (Black by default) */
  73269. get background(): string;
  73270. set background(value: string);
  73271. /** Gets or sets the width of each cell (20 by default) */
  73272. get cellWidth(): number;
  73273. set cellWidth(value: number);
  73274. /** Gets or sets the height of each cell (20 by default) */
  73275. get cellHeight(): number;
  73276. set cellHeight(value: number);
  73277. /** Gets or sets the tickness of minor lines (1 by default) */
  73278. get minorLineTickness(): number;
  73279. set minorLineTickness(value: number);
  73280. /** Gets or sets the color of minor lines (DarkGray by default) */
  73281. get minorLineColor(): string;
  73282. set minorLineColor(value: string);
  73283. /** Gets or sets the tickness of major lines (2 by default) */
  73284. get majorLineTickness(): number;
  73285. set majorLineTickness(value: number);
  73286. /** Gets or sets the color of major lines (White by default) */
  73287. get majorLineColor(): string;
  73288. set majorLineColor(value: string);
  73289. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73290. get majorLineFrequency(): number;
  73291. set majorLineFrequency(value: number);
  73292. /**
  73293. * Creates a new GridDisplayRectangle
  73294. * @param name defines the control name
  73295. */
  73296. constructor(name?: string | undefined);
  73297. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73298. protected _getTypeName(): string;
  73299. }
  73300. }
  73301. declare module BABYLON.GUI {
  73302. /**
  73303. * Class used to create slider controls based on images
  73304. */
  73305. export class ImageBasedSlider extends BaseSlider {
  73306. name?: string | undefined;
  73307. private _backgroundImage;
  73308. private _thumbImage;
  73309. private _valueBarImage;
  73310. private _tempMeasure;
  73311. get displayThumb(): boolean;
  73312. set displayThumb(value: boolean);
  73313. /**
  73314. * Gets or sets the image used to render the background
  73315. */
  73316. get backgroundImage(): Image;
  73317. set backgroundImage(value: Image);
  73318. /**
  73319. * Gets or sets the image used to render the value bar
  73320. */
  73321. get valueBarImage(): Image;
  73322. set valueBarImage(value: Image);
  73323. /**
  73324. * Gets or sets the image used to render the thumb
  73325. */
  73326. get thumbImage(): Image;
  73327. set thumbImage(value: Image);
  73328. /**
  73329. * Creates a new ImageBasedSlider
  73330. * @param name defines the control name
  73331. */
  73332. constructor(name?: string | undefined);
  73333. protected _getTypeName(): string;
  73334. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73335. }
  73336. }
  73337. declare module BABYLON.GUI {
  73338. /**
  73339. * Forcing an export so that this code will execute
  73340. * @hidden
  73341. */
  73342. const name = "Statics";
  73343. }
  73344. declare module BABYLON.GUI {
  73345. /**
  73346. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73347. */
  73348. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73349. /**
  73350. * Define the instrumented AdvancedDynamicTexture.
  73351. */
  73352. texture: AdvancedDynamicTexture;
  73353. private _captureRenderTime;
  73354. private _renderTime;
  73355. private _captureLayoutTime;
  73356. private _layoutTime;
  73357. private _onBeginRenderObserver;
  73358. private _onEndRenderObserver;
  73359. private _onBeginLayoutObserver;
  73360. private _onEndLayoutObserver;
  73361. /**
  73362. * Gets the perf counter used to capture render time
  73363. */
  73364. get renderTimeCounter(): BABYLON.PerfCounter;
  73365. /**
  73366. * Gets the perf counter used to capture layout time
  73367. */
  73368. get layoutTimeCounter(): BABYLON.PerfCounter;
  73369. /**
  73370. * Enable or disable the render time capture
  73371. */
  73372. get captureRenderTime(): boolean;
  73373. set captureRenderTime(value: boolean);
  73374. /**
  73375. * Enable or disable the layout time capture
  73376. */
  73377. get captureLayoutTime(): boolean;
  73378. set captureLayoutTime(value: boolean);
  73379. /**
  73380. * Instantiates a new advanced dynamic texture instrumentation.
  73381. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73382. * @param texture Defines the AdvancedDynamicTexture to instrument
  73383. */
  73384. constructor(
  73385. /**
  73386. * Define the instrumented AdvancedDynamicTexture.
  73387. */
  73388. texture: AdvancedDynamicTexture);
  73389. /**
  73390. * Dispose and release associated resources.
  73391. */
  73392. dispose(): void;
  73393. }
  73394. }
  73395. declare module BABYLON.GUI {
  73396. /**
  73397. * Class used to load GUI via XML.
  73398. */
  73399. export class XmlLoader {
  73400. private _nodes;
  73401. private _nodeTypes;
  73402. private _isLoaded;
  73403. private _objectAttributes;
  73404. private _parentClass;
  73405. /**
  73406. * Create a new xml loader
  73407. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73408. */
  73409. constructor(parentClass?: null);
  73410. private _getChainElement;
  73411. private _getClassAttribute;
  73412. private _createGuiElement;
  73413. private _parseGrid;
  73414. private _parseElement;
  73415. private _prepareSourceElement;
  73416. private _parseElementsFromSource;
  73417. private _parseXml;
  73418. /**
  73419. * Gets if the loading has finished.
  73420. * @returns whether the loading has finished or not
  73421. */
  73422. isLoaded(): boolean;
  73423. /**
  73424. * Gets a loaded node / control by id.
  73425. * @param id the Controls id set in the xml
  73426. * @returns element of type Control
  73427. */
  73428. getNodeById(id: string): any;
  73429. /**
  73430. * Gets all loaded nodes / controls
  73431. * @returns Array of controls
  73432. */
  73433. getNodes(): any;
  73434. /**
  73435. * Initiates the xml layout loading
  73436. * @param xmlFile defines the xml layout to load
  73437. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73438. * @param callback defines the callback called on layout load.
  73439. */
  73440. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73441. }
  73442. }
  73443. declare module BABYLON.GUI {
  73444. /**
  73445. * Class used to create containers for controls
  73446. */
  73447. export class Container3D extends Control3D {
  73448. private _blockLayout;
  73449. /**
  73450. * Gets the list of child controls
  73451. */
  73452. protected _children: Control3D[];
  73453. /**
  73454. * Gets the list of child controls
  73455. */
  73456. get children(): Array<Control3D>;
  73457. /**
  73458. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73459. * This is helpful to optimize layout operation when adding multiple children in a row
  73460. */
  73461. get blockLayout(): boolean;
  73462. set blockLayout(value: boolean);
  73463. /**
  73464. * Creates a new container
  73465. * @param name defines the container name
  73466. */
  73467. constructor(name?: string);
  73468. /**
  73469. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73470. * @returns the current container
  73471. */
  73472. updateLayout(): Container3D;
  73473. /**
  73474. * Gets a boolean indicating if the given control is in the children of this control
  73475. * @param control defines the control to check
  73476. * @returns true if the control is in the child list
  73477. */
  73478. containsControl(control: Control3D): boolean;
  73479. /**
  73480. * Adds a control to the children of this control
  73481. * @param control defines the control to add
  73482. * @returns the current container
  73483. */
  73484. addControl(control: Control3D): Container3D;
  73485. /**
  73486. * This function will be called everytime a new control is added
  73487. */
  73488. protected _arrangeChildren(): void;
  73489. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73490. /**
  73491. * Removes a control from the children of this control
  73492. * @param control defines the control to remove
  73493. * @returns the current container
  73494. */
  73495. removeControl(control: Control3D): Container3D;
  73496. protected _getTypeName(): string;
  73497. /**
  73498. * Releases all associated resources
  73499. */
  73500. dispose(): void;
  73501. /** Control rotation will remain unchanged */
  73502. static readonly UNSET_ORIENTATION: number;
  73503. /** Control will rotate to make it look at sphere central axis */
  73504. static readonly FACEORIGIN_ORIENTATION: number;
  73505. /** Control will rotate to make it look back at sphere central axis */
  73506. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73507. /** Control will rotate to look at z axis (0, 0, 1) */
  73508. static readonly FACEFORWARD_ORIENTATION: number;
  73509. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73510. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73511. }
  73512. }
  73513. declare module BABYLON.GUI {
  73514. /**
  73515. * Class used to manage 3D user interface
  73516. * @see http://doc.babylonjs.com/how_to/gui3d
  73517. */
  73518. export class GUI3DManager implements BABYLON.IDisposable {
  73519. private _scene;
  73520. private _sceneDisposeObserver;
  73521. private _utilityLayer;
  73522. private _rootContainer;
  73523. private _pointerObserver;
  73524. private _pointerOutObserver;
  73525. /** @hidden */
  73526. _lastPickedControl: Control3D;
  73527. /** @hidden */
  73528. _lastControlOver: {
  73529. [pointerId: number]: Control3D;
  73530. };
  73531. /** @hidden */
  73532. _lastControlDown: {
  73533. [pointerId: number]: Control3D;
  73534. };
  73535. /**
  73536. * BABYLON.Observable raised when the point picked by the pointer events changed
  73537. */
  73538. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73539. /** @hidden */
  73540. _sharedMaterials: {
  73541. [key: string]: BABYLON.Material;
  73542. };
  73543. /** Gets the hosting scene */
  73544. get scene(): BABYLON.Scene;
  73545. /** Gets associated utility layer */
  73546. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73547. /**
  73548. * Creates a new GUI3DManager
  73549. * @param scene
  73550. */
  73551. constructor(scene?: BABYLON.Scene);
  73552. private _handlePointerOut;
  73553. private _doPicking;
  73554. /**
  73555. * Gets the root container
  73556. */
  73557. get rootContainer(): Container3D;
  73558. /**
  73559. * Gets a boolean indicating if the given control is in the root child list
  73560. * @param control defines the control to check
  73561. * @returns true if the control is in the root child list
  73562. */
  73563. containsControl(control: Control3D): boolean;
  73564. /**
  73565. * Adds a control to the root child list
  73566. * @param control defines the control to add
  73567. * @returns the current manager
  73568. */
  73569. addControl(control: Control3D): GUI3DManager;
  73570. /**
  73571. * Removes a control from the root child list
  73572. * @param control defines the control to remove
  73573. * @returns the current container
  73574. */
  73575. removeControl(control: Control3D): GUI3DManager;
  73576. /**
  73577. * Releases all associated resources
  73578. */
  73579. dispose(): void;
  73580. }
  73581. }
  73582. declare module BABYLON.GUI {
  73583. /**
  73584. * Class used to transport BABYLON.Vector3 information for pointer events
  73585. */
  73586. export class Vector3WithInfo extends BABYLON.Vector3 {
  73587. /** defines the current mouse button index */
  73588. buttonIndex: number;
  73589. /**
  73590. * Creates a new Vector3WithInfo
  73591. * @param source defines the vector3 data to transport
  73592. * @param buttonIndex defines the current mouse button index
  73593. */
  73594. constructor(source: BABYLON.Vector3,
  73595. /** defines the current mouse button index */
  73596. buttonIndex?: number);
  73597. }
  73598. }
  73599. declare module BABYLON.GUI {
  73600. /**
  73601. * Class used as base class for controls
  73602. */
  73603. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73604. /** Defines the control name */
  73605. name?: string | undefined;
  73606. /** @hidden */
  73607. _host: GUI3DManager;
  73608. private _node;
  73609. private _downCount;
  73610. private _enterCount;
  73611. private _downPointerIds;
  73612. private _isVisible;
  73613. /** Gets or sets the control position in world space */
  73614. get position(): BABYLON.Vector3;
  73615. set position(value: BABYLON.Vector3);
  73616. /** Gets or sets the control scaling in world space */
  73617. get scaling(): BABYLON.Vector3;
  73618. set scaling(value: BABYLON.Vector3);
  73619. /** Callback used to start pointer enter animation */
  73620. pointerEnterAnimation: () => void;
  73621. /** Callback used to start pointer out animation */
  73622. pointerOutAnimation: () => void;
  73623. /** Callback used to start pointer down animation */
  73624. pointerDownAnimation: () => void;
  73625. /** Callback used to start pointer up animation */
  73626. pointerUpAnimation: () => void;
  73627. /**
  73628. * An event triggered when the pointer move over the control
  73629. */
  73630. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73631. /**
  73632. * An event triggered when the pointer move out of the control
  73633. */
  73634. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73635. /**
  73636. * An event triggered when the pointer taps the control
  73637. */
  73638. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73639. /**
  73640. * An event triggered when pointer is up
  73641. */
  73642. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73643. /**
  73644. * An event triggered when a control is clicked on (with a mouse)
  73645. */
  73646. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73647. /**
  73648. * An event triggered when pointer enters the control
  73649. */
  73650. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73651. /**
  73652. * Gets or sets the parent container
  73653. */
  73654. parent: BABYLON.Nullable<Container3D>;
  73655. private _behaviors;
  73656. /**
  73657. * Gets the list of attached behaviors
  73658. * @see http://doc.babylonjs.com/features/behaviour
  73659. */
  73660. get behaviors(): BABYLON.Behavior<Control3D>[];
  73661. /**
  73662. * Attach a behavior to the control
  73663. * @see http://doc.babylonjs.com/features/behaviour
  73664. * @param behavior defines the behavior to attach
  73665. * @returns the current control
  73666. */
  73667. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73668. /**
  73669. * Remove an attached behavior
  73670. * @see http://doc.babylonjs.com/features/behaviour
  73671. * @param behavior defines the behavior to attach
  73672. * @returns the current control
  73673. */
  73674. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73675. /**
  73676. * Gets an attached behavior by name
  73677. * @param name defines the name of the behavior to look for
  73678. * @see http://doc.babylonjs.com/features/behaviour
  73679. * @returns null if behavior was not found else the requested behavior
  73680. */
  73681. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73682. /** Gets or sets a boolean indicating if the control is visible */
  73683. get isVisible(): boolean;
  73684. set isVisible(value: boolean);
  73685. /**
  73686. * Creates a new control
  73687. * @param name defines the control name
  73688. */
  73689. constructor(
  73690. /** Defines the control name */
  73691. name?: string | undefined);
  73692. /**
  73693. * Gets a string representing the class name
  73694. */
  73695. get typeName(): string;
  73696. /**
  73697. * Get the current class name of the control.
  73698. * @returns current class name
  73699. */
  73700. getClassName(): string;
  73701. protected _getTypeName(): string;
  73702. /**
  73703. * Gets the transform node used by this control
  73704. */
  73705. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73706. /**
  73707. * Gets the mesh used to render this control
  73708. */
  73709. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73710. /**
  73711. * Link the control as child of the given node
  73712. * @param node defines the node to link to. Use null to unlink the control
  73713. * @returns the current control
  73714. */
  73715. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73716. /** @hidden **/
  73717. _prepareNode(scene: BABYLON.Scene): void;
  73718. /**
  73719. * Node creation.
  73720. * Can be overriden by children
  73721. * @param scene defines the scene where the node must be attached
  73722. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73723. */
  73724. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73725. /**
  73726. * Affect a material to the given mesh
  73727. * @param mesh defines the mesh which will represent the control
  73728. */
  73729. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73730. /** @hidden */
  73731. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73732. /** @hidden */
  73733. _onPointerEnter(target: Control3D): boolean;
  73734. /** @hidden */
  73735. _onPointerOut(target: Control3D): void;
  73736. /** @hidden */
  73737. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73738. /** @hidden */
  73739. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73740. /** @hidden */
  73741. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73742. /** @hidden */
  73743. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73744. /** @hidden */
  73745. _disposeNode(): void;
  73746. /**
  73747. * Releases all associated resources
  73748. */
  73749. dispose(): void;
  73750. }
  73751. }
  73752. declare module BABYLON.GUI {
  73753. /**
  73754. * Class used as a root to all buttons
  73755. */
  73756. export class AbstractButton3D extends Control3D {
  73757. /**
  73758. * Creates a new button
  73759. * @param name defines the control name
  73760. */
  73761. constructor(name?: string);
  73762. protected _getTypeName(): string;
  73763. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73764. }
  73765. }
  73766. declare module BABYLON.GUI {
  73767. /**
  73768. * Class used to create a button in 3D
  73769. */
  73770. export class Button3D extends AbstractButton3D {
  73771. /** @hidden */
  73772. protected _currentMaterial: BABYLON.Material;
  73773. private _facadeTexture;
  73774. private _content;
  73775. private _contentResolution;
  73776. private _contentScaleRatio;
  73777. /**
  73778. * Gets or sets the texture resolution used to render content (512 by default)
  73779. */
  73780. get contentResolution(): BABYLON.int;
  73781. set contentResolution(value: BABYLON.int);
  73782. /**
  73783. * Gets or sets the texture scale ratio used to render content (2 by default)
  73784. */
  73785. get contentScaleRatio(): number;
  73786. set contentScaleRatio(value: number);
  73787. protected _disposeFacadeTexture(): void;
  73788. protected _resetContent(): void;
  73789. /**
  73790. * Creates a new button
  73791. * @param name defines the control name
  73792. */
  73793. constructor(name?: string);
  73794. /**
  73795. * Gets or sets the GUI 2D content used to display the button's facade
  73796. */
  73797. get content(): Control;
  73798. set content(value: Control);
  73799. /**
  73800. * Apply the facade texture (created from the content property).
  73801. * This function can be overloaded by child classes
  73802. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73803. */
  73804. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73805. protected _getTypeName(): string;
  73806. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73807. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73808. /**
  73809. * Releases all associated resources
  73810. */
  73811. dispose(): void;
  73812. }
  73813. }
  73814. declare module BABYLON.GUI {
  73815. /**
  73816. * Abstract class used to create a container panel deployed on the surface of a volume
  73817. */
  73818. export abstract class VolumeBasedPanel extends Container3D {
  73819. private _columns;
  73820. private _rows;
  73821. private _rowThenColum;
  73822. private _orientation;
  73823. protected _cellWidth: number;
  73824. protected _cellHeight: number;
  73825. /**
  73826. * Gets or sets the distance between elements
  73827. */
  73828. margin: number;
  73829. /**
  73830. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73831. * | Value | Type | Description |
  73832. * | ----- | ----------------------------------- | ----------- |
  73833. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73834. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73835. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73836. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73837. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73838. */
  73839. get orientation(): number;
  73840. set orientation(value: number);
  73841. /**
  73842. * Gets or sets the number of columns requested (10 by default).
  73843. * The panel will automatically compute the number of rows based on number of child controls.
  73844. */
  73845. get columns(): BABYLON.int;
  73846. set columns(value: BABYLON.int);
  73847. /**
  73848. * Gets or sets a the number of rows requested.
  73849. * The panel will automatically compute the number of columns based on number of child controls.
  73850. */
  73851. get rows(): BABYLON.int;
  73852. set rows(value: BABYLON.int);
  73853. /**
  73854. * Creates new VolumeBasedPanel
  73855. */
  73856. constructor();
  73857. protected _arrangeChildren(): void;
  73858. /** Child classes must implement this function to provide correct control positioning */
  73859. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73860. /** Child classes can implement this function to provide additional processing */
  73861. protected _finalProcessing(): void;
  73862. }
  73863. }
  73864. declare module BABYLON.GUI {
  73865. /**
  73866. * Class used to create a container panel deployed on the surface of a cylinder
  73867. */
  73868. export class CylinderPanel extends VolumeBasedPanel {
  73869. private _radius;
  73870. /**
  73871. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73872. */
  73873. get radius(): BABYLON.float;
  73874. set radius(value: BABYLON.float);
  73875. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73876. private _cylindricalMapping;
  73877. }
  73878. }
  73879. declare module BABYLON.GUI {
  73880. /** @hidden */
  73881. export var fluentVertexShader: {
  73882. name: string;
  73883. shader: string;
  73884. };
  73885. }
  73886. declare module BABYLON.GUI {
  73887. /** @hidden */
  73888. export var fluentPixelShader: {
  73889. name: string;
  73890. shader: string;
  73891. };
  73892. }
  73893. declare module BABYLON.GUI {
  73894. /** @hidden */
  73895. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73896. INNERGLOW: boolean;
  73897. BORDER: boolean;
  73898. HOVERLIGHT: boolean;
  73899. TEXTURE: boolean;
  73900. constructor();
  73901. }
  73902. /**
  73903. * Class used to render controls with fluent desgin
  73904. */
  73905. export class FluentMaterial extends BABYLON.PushMaterial {
  73906. /**
  73907. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73908. */
  73909. innerGlowColorIntensity: number;
  73910. /**
  73911. * Gets or sets the inner glow color (white by default)
  73912. */
  73913. innerGlowColor: BABYLON.Color3;
  73914. /**
  73915. * Gets or sets alpha value (default is 1.0)
  73916. */
  73917. alpha: number;
  73918. /**
  73919. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73920. */
  73921. albedoColor: BABYLON.Color3;
  73922. /**
  73923. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73924. */
  73925. renderBorders: boolean;
  73926. /**
  73927. * Gets or sets border width (default is 0.5)
  73928. */
  73929. borderWidth: number;
  73930. /**
  73931. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73932. */
  73933. edgeSmoothingValue: number;
  73934. /**
  73935. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73936. */
  73937. borderMinValue: number;
  73938. /**
  73939. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73940. */
  73941. renderHoverLight: boolean;
  73942. /**
  73943. * Gets or sets the radius used to render the hover light (default is 1.0)
  73944. */
  73945. hoverRadius: number;
  73946. /**
  73947. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73948. */
  73949. hoverColor: BABYLON.Color4;
  73950. /**
  73951. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73952. */
  73953. hoverPosition: BABYLON.Vector3;
  73954. private _albedoTexture;
  73955. /** Gets or sets the texture to use for albedo color */
  73956. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73957. /**
  73958. * Creates a new Fluent material
  73959. * @param name defines the name of the material
  73960. * @param scene defines the hosting scene
  73961. */
  73962. constructor(name: string, scene: BABYLON.Scene);
  73963. needAlphaBlending(): boolean;
  73964. needAlphaTesting(): boolean;
  73965. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73966. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73967. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73968. getActiveTextures(): BABYLON.BaseTexture[];
  73969. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73970. dispose(forceDisposeEffect?: boolean): void;
  73971. clone(name: string): FluentMaterial;
  73972. serialize(): any;
  73973. getClassName(): string;
  73974. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73975. }
  73976. }
  73977. declare module BABYLON.GUI {
  73978. /**
  73979. * Class used to create a holographic button in 3D
  73980. */
  73981. export class HolographicButton extends Button3D {
  73982. private _backPlate;
  73983. private _textPlate;
  73984. private _frontPlate;
  73985. private _text;
  73986. private _imageUrl;
  73987. private _shareMaterials;
  73988. private _frontMaterial;
  73989. private _backMaterial;
  73990. private _plateMaterial;
  73991. private _pickedPointObserver;
  73992. private _tooltipFade;
  73993. private _tooltipTextBlock;
  73994. private _tooltipTexture;
  73995. private _tooltipMesh;
  73996. private _tooltipHoverObserver;
  73997. private _tooltipOutObserver;
  73998. private _disposeTooltip;
  73999. /**
  74000. * Rendering ground id of all the mesh in the button
  74001. */
  74002. set renderingGroupId(id: number);
  74003. get renderingGroupId(): number;
  74004. /**
  74005. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  74006. */
  74007. set tooltipText(text: BABYLON.Nullable<string>);
  74008. get tooltipText(): BABYLON.Nullable<string>;
  74009. /**
  74010. * Gets or sets text for the button
  74011. */
  74012. get text(): string;
  74013. set text(value: string);
  74014. /**
  74015. * Gets or sets the image url for the button
  74016. */
  74017. get imageUrl(): string;
  74018. set imageUrl(value: string);
  74019. /**
  74020. * Gets the back material used by this button
  74021. */
  74022. get backMaterial(): FluentMaterial;
  74023. /**
  74024. * Gets the front material used by this button
  74025. */
  74026. get frontMaterial(): FluentMaterial;
  74027. /**
  74028. * Gets the plate material used by this button
  74029. */
  74030. get plateMaterial(): BABYLON.StandardMaterial;
  74031. /**
  74032. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  74033. */
  74034. get shareMaterials(): boolean;
  74035. /**
  74036. * Creates a new button
  74037. * @param name defines the control name
  74038. */
  74039. constructor(name?: string, shareMaterials?: boolean);
  74040. protected _getTypeName(): string;
  74041. private _rebuildContent;
  74042. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74043. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  74044. private _createBackMaterial;
  74045. private _createFrontMaterial;
  74046. private _createPlateMaterial;
  74047. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  74048. /**
  74049. * Releases all associated resources
  74050. */
  74051. dispose(): void;
  74052. }
  74053. }
  74054. declare module BABYLON.GUI {
  74055. /**
  74056. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  74057. */
  74058. export class MeshButton3D extends Button3D {
  74059. /** @hidden */
  74060. protected _currentMesh: BABYLON.Mesh;
  74061. /**
  74062. * Creates a new 3D button based on a mesh
  74063. * @param mesh mesh to become a 3D button
  74064. * @param name defines the control name
  74065. */
  74066. constructor(mesh: BABYLON.Mesh, name?: string);
  74067. protected _getTypeName(): string;
  74068. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  74069. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  74070. }
  74071. }
  74072. declare module BABYLON.GUI {
  74073. /**
  74074. * Class used to create a container panel deployed on the surface of a plane
  74075. */
  74076. export class PlanePanel extends VolumeBasedPanel {
  74077. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74078. }
  74079. }
  74080. declare module BABYLON.GUI {
  74081. /**
  74082. * Class used to create a container panel where items get randomized planar mapping
  74083. */
  74084. export class ScatterPanel extends VolumeBasedPanel {
  74085. private _iteration;
  74086. /**
  74087. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  74088. */
  74089. get iteration(): BABYLON.float;
  74090. set iteration(value: BABYLON.float);
  74091. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74092. private _scatterMapping;
  74093. protected _finalProcessing(): void;
  74094. }
  74095. }
  74096. declare module BABYLON.GUI {
  74097. /**
  74098. * Class used to create a container panel deployed on the surface of a sphere
  74099. */
  74100. export class SpherePanel extends VolumeBasedPanel {
  74101. private _radius;
  74102. /**
  74103. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74104. */
  74105. get radius(): BABYLON.float;
  74106. set radius(value: BABYLON.float);
  74107. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74108. private _sphericalMapping;
  74109. }
  74110. }
  74111. declare module BABYLON.GUI {
  74112. /**
  74113. * Class used to create a stack panel in 3D on XY plane
  74114. */
  74115. export class StackPanel3D extends Container3D {
  74116. private _isVertical;
  74117. /**
  74118. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74119. */
  74120. get isVertical(): boolean;
  74121. set isVertical(value: boolean);
  74122. /**
  74123. * Gets or sets the distance between elements
  74124. */
  74125. margin: number;
  74126. /**
  74127. * Creates new StackPanel
  74128. * @param isVertical
  74129. */
  74130. constructor(isVertical?: boolean);
  74131. protected _arrangeChildren(): void;
  74132. }
  74133. }
  74134. declare module BABYLON {
  74135. /**
  74136. * Configuration for glTF validation
  74137. */
  74138. export interface IGLTFValidationConfiguration {
  74139. /**
  74140. * The url of the glTF validator.
  74141. */
  74142. url: string;
  74143. }
  74144. /**
  74145. * glTF validation
  74146. */
  74147. export class GLTFValidation {
  74148. /**
  74149. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74150. */
  74151. static Configuration: IGLTFValidationConfiguration;
  74152. private static _LoadScriptPromise;
  74153. /**
  74154. * Validate a glTF asset using the glTF-Validator.
  74155. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74156. * @param rootUrl The root url for the glTF
  74157. * @param fileName The file name for the glTF
  74158. * @param getExternalResource The callback to get external resources for the glTF validator
  74159. * @returns A promise that resolves with the glTF validation results once complete
  74160. */
  74161. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74162. }
  74163. }
  74164. declare module BABYLON {
  74165. /**
  74166. * Mode that determines the coordinate system to use.
  74167. */
  74168. export enum GLTFLoaderCoordinateSystemMode {
  74169. /**
  74170. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74171. */
  74172. AUTO = 0,
  74173. /**
  74174. * Sets the useRightHandedSystem flag on the scene.
  74175. */
  74176. FORCE_RIGHT_HANDED = 1
  74177. }
  74178. /**
  74179. * Mode that determines what animations will start.
  74180. */
  74181. export enum GLTFLoaderAnimationStartMode {
  74182. /**
  74183. * No animation will start.
  74184. */
  74185. NONE = 0,
  74186. /**
  74187. * The first animation will start.
  74188. */
  74189. FIRST = 1,
  74190. /**
  74191. * All animations will start.
  74192. */
  74193. ALL = 2
  74194. }
  74195. /**
  74196. * Interface that contains the data for the glTF asset.
  74197. */
  74198. export interface IGLTFLoaderData {
  74199. /**
  74200. * The object that represents the glTF JSON.
  74201. */
  74202. json: Object;
  74203. /**
  74204. * The BIN chunk of a binary glTF.
  74205. */
  74206. bin: Nullable<IDataBuffer>;
  74207. }
  74208. /**
  74209. * Interface for extending the loader.
  74210. */
  74211. export interface IGLTFLoaderExtension {
  74212. /**
  74213. * The name of this extension.
  74214. */
  74215. readonly name: string;
  74216. /**
  74217. * Defines whether this extension is enabled.
  74218. */
  74219. enabled: boolean;
  74220. /**
  74221. * Defines the order of this extension.
  74222. * The loader sorts the extensions using these values when loading.
  74223. */
  74224. order?: number;
  74225. }
  74226. /**
  74227. * Loader state.
  74228. */
  74229. export enum GLTFLoaderState {
  74230. /**
  74231. * The asset is loading.
  74232. */
  74233. LOADING = 0,
  74234. /**
  74235. * The asset is ready for rendering.
  74236. */
  74237. READY = 1,
  74238. /**
  74239. * The asset is completely loaded.
  74240. */
  74241. COMPLETE = 2
  74242. }
  74243. /** @hidden */
  74244. export interface IImportMeshAsyncOutput {
  74245. meshes: AbstractMesh[];
  74246. particleSystems: IParticleSystem[];
  74247. skeletons: Skeleton[];
  74248. animationGroups: AnimationGroup[];
  74249. lights: Light[];
  74250. transformNodes: TransformNode[];
  74251. }
  74252. /** @hidden */
  74253. export interface IGLTFLoader extends IDisposable {
  74254. readonly state: Nullable<GLTFLoaderState>;
  74255. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  74256. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74257. }
  74258. /**
  74259. * File loader for loading glTF files into a scene.
  74260. */
  74261. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74262. /** @hidden */
  74263. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74264. /** @hidden */
  74265. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74266. /**
  74267. * Raised when the asset has been parsed
  74268. */
  74269. onParsedObservable: Observable<IGLTFLoaderData>;
  74270. private _onParsedObserver;
  74271. /**
  74272. * Raised when the asset has been parsed
  74273. */
  74274. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74275. /**
  74276. * 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.
  74277. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74278. * Defaults to true.
  74279. * @hidden
  74280. */
  74281. static IncrementalLoading: boolean;
  74282. /**
  74283. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74284. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74285. * @hidden
  74286. */
  74287. static HomogeneousCoordinates: boolean;
  74288. /**
  74289. * The coordinate system mode. Defaults to AUTO.
  74290. */
  74291. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74292. /**
  74293. * The animation start mode. Defaults to FIRST.
  74294. */
  74295. animationStartMode: GLTFLoaderAnimationStartMode;
  74296. /**
  74297. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74298. */
  74299. compileMaterials: boolean;
  74300. /**
  74301. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74302. */
  74303. useClipPlane: boolean;
  74304. /**
  74305. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74306. */
  74307. compileShadowGenerators: boolean;
  74308. /**
  74309. * Defines if the Alpha blended materials are only applied as coverage.
  74310. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74311. * If true, no extra effects are applied to transparent pixels.
  74312. */
  74313. transparencyAsCoverage: boolean;
  74314. /**
  74315. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74316. * Enabling will disable offline support and glTF validator.
  74317. * Defaults to false.
  74318. */
  74319. useRangeRequests: boolean;
  74320. /**
  74321. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74322. */
  74323. createInstances: boolean;
  74324. /**
  74325. * Function called before loading a url referenced by the asset.
  74326. */
  74327. preprocessUrlAsync: (url: string) => Promise<string>;
  74328. /**
  74329. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74330. */
  74331. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74332. private _onMeshLoadedObserver;
  74333. /**
  74334. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74335. */
  74336. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74337. /**
  74338. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74339. */
  74340. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74341. private _onTextureLoadedObserver;
  74342. /**
  74343. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74344. */
  74345. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74346. /**
  74347. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74348. */
  74349. readonly onMaterialLoadedObservable: Observable<Material>;
  74350. private _onMaterialLoadedObserver;
  74351. /**
  74352. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74353. */
  74354. set onMaterialLoaded(callback: (material: Material) => void);
  74355. /**
  74356. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74357. */
  74358. readonly onCameraLoadedObservable: Observable<Camera>;
  74359. private _onCameraLoadedObserver;
  74360. /**
  74361. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74362. */
  74363. set onCameraLoaded(callback: (camera: Camera) => void);
  74364. /**
  74365. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74366. * For assets with LODs, raised when all of the LODs are complete.
  74367. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74368. */
  74369. readonly onCompleteObservable: Observable<void>;
  74370. private _onCompleteObserver;
  74371. /**
  74372. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74373. * For assets with LODs, raised when all of the LODs are complete.
  74374. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74375. */
  74376. set onComplete(callback: () => void);
  74377. /**
  74378. * Observable raised when an error occurs.
  74379. */
  74380. readonly onErrorObservable: Observable<any>;
  74381. private _onErrorObserver;
  74382. /**
  74383. * Callback raised when an error occurs.
  74384. */
  74385. set onError(callback: (reason: any) => void);
  74386. /**
  74387. * Observable raised after the loader is disposed.
  74388. */
  74389. readonly onDisposeObservable: Observable<void>;
  74390. private _onDisposeObserver;
  74391. /**
  74392. * Callback raised after the loader is disposed.
  74393. */
  74394. set onDispose(callback: () => void);
  74395. /**
  74396. * Observable raised after a loader extension is created.
  74397. * Set additional options for a loader extension in this event.
  74398. */
  74399. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74400. private _onExtensionLoadedObserver;
  74401. /**
  74402. * Callback raised after a loader extension is created.
  74403. */
  74404. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74405. /**
  74406. * Defines if the loader logging is enabled.
  74407. */
  74408. get loggingEnabled(): boolean;
  74409. set loggingEnabled(value: boolean);
  74410. /**
  74411. * Defines if the loader should capture performance counters.
  74412. */
  74413. get capturePerformanceCounters(): boolean;
  74414. set capturePerformanceCounters(value: boolean);
  74415. /**
  74416. * Defines if the loader should validate the asset.
  74417. */
  74418. validate: boolean;
  74419. /**
  74420. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74421. */
  74422. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74423. private _onValidatedObserver;
  74424. /**
  74425. * Callback raised after a loader extension is created.
  74426. */
  74427. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74428. private _loader;
  74429. /**
  74430. * Name of the loader ("gltf")
  74431. */
  74432. name: string;
  74433. /** @hidden */
  74434. extensions: ISceneLoaderPluginExtensions;
  74435. /**
  74436. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74437. */
  74438. dispose(): void;
  74439. /** @hidden */
  74440. _clear(): void;
  74441. /** @hidden */
  74442. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74443. /** @hidden */
  74444. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74445. /** @hidden */
  74446. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74447. meshes: AbstractMesh[];
  74448. particleSystems: IParticleSystem[];
  74449. skeletons: Skeleton[];
  74450. animationGroups: AnimationGroup[];
  74451. }>;
  74452. /** @hidden */
  74453. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74454. /** @hidden */
  74455. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74456. /** @hidden */
  74457. canDirectLoad(data: string): boolean;
  74458. /** @hidden */
  74459. directLoad(scene: Scene, data: string): any;
  74460. /**
  74461. * The callback that allows custom handling of the root url based on the response url.
  74462. * @param rootUrl the original root url
  74463. * @param responseURL the response url if available
  74464. * @returns the new root url
  74465. */
  74466. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74467. /** @hidden */
  74468. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74469. /**
  74470. * The loader state or null if the loader is not active.
  74471. */
  74472. get loaderState(): Nullable<GLTFLoaderState>;
  74473. /**
  74474. * Returns a promise that resolves when the asset is completely loaded.
  74475. * @returns a promise that resolves when the asset is completely loaded.
  74476. */
  74477. whenCompleteAsync(): Promise<void>;
  74478. private _validate;
  74479. private _getLoader;
  74480. private _parseJson;
  74481. private _unpackBinaryAsync;
  74482. private _unpackBinaryV1Async;
  74483. private _unpackBinaryV2Async;
  74484. private static _parseVersion;
  74485. private static _compareVersion;
  74486. private static readonly _logSpaces;
  74487. private _logIndentLevel;
  74488. private _loggingEnabled;
  74489. /** @hidden */
  74490. _log: (message: string) => void;
  74491. /** @hidden */
  74492. _logOpen(message: string): void;
  74493. /** @hidden */
  74494. _logClose(): void;
  74495. private _logEnabled;
  74496. private _logDisabled;
  74497. private _capturePerformanceCounters;
  74498. /** @hidden */
  74499. _startPerformanceCounter: (counterName: string) => void;
  74500. /** @hidden */
  74501. _endPerformanceCounter: (counterName: string) => void;
  74502. private _startPerformanceCounterEnabled;
  74503. private _startPerformanceCounterDisabled;
  74504. private _endPerformanceCounterEnabled;
  74505. private _endPerformanceCounterDisabled;
  74506. }
  74507. }
  74508. declare module BABYLON.GLTF1 {
  74509. /**
  74510. * Enums
  74511. * @hidden
  74512. */
  74513. export enum EComponentType {
  74514. BYTE = 5120,
  74515. UNSIGNED_BYTE = 5121,
  74516. SHORT = 5122,
  74517. UNSIGNED_SHORT = 5123,
  74518. FLOAT = 5126
  74519. }
  74520. /** @hidden */
  74521. export enum EShaderType {
  74522. FRAGMENT = 35632,
  74523. VERTEX = 35633
  74524. }
  74525. /** @hidden */
  74526. export enum EParameterType {
  74527. BYTE = 5120,
  74528. UNSIGNED_BYTE = 5121,
  74529. SHORT = 5122,
  74530. UNSIGNED_SHORT = 5123,
  74531. INT = 5124,
  74532. UNSIGNED_INT = 5125,
  74533. FLOAT = 5126,
  74534. FLOAT_VEC2 = 35664,
  74535. FLOAT_VEC3 = 35665,
  74536. FLOAT_VEC4 = 35666,
  74537. INT_VEC2 = 35667,
  74538. INT_VEC3 = 35668,
  74539. INT_VEC4 = 35669,
  74540. BOOL = 35670,
  74541. BOOL_VEC2 = 35671,
  74542. BOOL_VEC3 = 35672,
  74543. BOOL_VEC4 = 35673,
  74544. FLOAT_MAT2 = 35674,
  74545. FLOAT_MAT3 = 35675,
  74546. FLOAT_MAT4 = 35676,
  74547. SAMPLER_2D = 35678
  74548. }
  74549. /** @hidden */
  74550. export enum ETextureWrapMode {
  74551. CLAMP_TO_EDGE = 33071,
  74552. MIRRORED_REPEAT = 33648,
  74553. REPEAT = 10497
  74554. }
  74555. /** @hidden */
  74556. export enum ETextureFilterType {
  74557. NEAREST = 9728,
  74558. LINEAR = 9728,
  74559. NEAREST_MIPMAP_NEAREST = 9984,
  74560. LINEAR_MIPMAP_NEAREST = 9985,
  74561. NEAREST_MIPMAP_LINEAR = 9986,
  74562. LINEAR_MIPMAP_LINEAR = 9987
  74563. }
  74564. /** @hidden */
  74565. export enum ETextureFormat {
  74566. ALPHA = 6406,
  74567. RGB = 6407,
  74568. RGBA = 6408,
  74569. LUMINANCE = 6409,
  74570. LUMINANCE_ALPHA = 6410
  74571. }
  74572. /** @hidden */
  74573. export enum ECullingType {
  74574. FRONT = 1028,
  74575. BACK = 1029,
  74576. FRONT_AND_BACK = 1032
  74577. }
  74578. /** @hidden */
  74579. export enum EBlendingFunction {
  74580. ZERO = 0,
  74581. ONE = 1,
  74582. SRC_COLOR = 768,
  74583. ONE_MINUS_SRC_COLOR = 769,
  74584. DST_COLOR = 774,
  74585. ONE_MINUS_DST_COLOR = 775,
  74586. SRC_ALPHA = 770,
  74587. ONE_MINUS_SRC_ALPHA = 771,
  74588. DST_ALPHA = 772,
  74589. ONE_MINUS_DST_ALPHA = 773,
  74590. CONSTANT_COLOR = 32769,
  74591. ONE_MINUS_CONSTANT_COLOR = 32770,
  74592. CONSTANT_ALPHA = 32771,
  74593. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74594. SRC_ALPHA_SATURATE = 776
  74595. }
  74596. /** @hidden */
  74597. export interface IGLTFProperty {
  74598. extensions?: {
  74599. [key: string]: any;
  74600. };
  74601. extras?: Object;
  74602. }
  74603. /** @hidden */
  74604. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74605. name?: string;
  74606. }
  74607. /** @hidden */
  74608. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74609. bufferView: string;
  74610. byteOffset: number;
  74611. byteStride: number;
  74612. count: number;
  74613. type: string;
  74614. componentType: EComponentType;
  74615. max?: number[];
  74616. min?: number[];
  74617. name?: string;
  74618. }
  74619. /** @hidden */
  74620. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74621. buffer: string;
  74622. byteOffset: number;
  74623. byteLength: number;
  74624. byteStride: number;
  74625. target?: number;
  74626. }
  74627. /** @hidden */
  74628. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74629. uri: string;
  74630. byteLength?: number;
  74631. type?: string;
  74632. }
  74633. /** @hidden */
  74634. export interface IGLTFShader extends IGLTFChildRootProperty {
  74635. uri: string;
  74636. type: EShaderType;
  74637. }
  74638. /** @hidden */
  74639. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74640. attributes: string[];
  74641. fragmentShader: string;
  74642. vertexShader: string;
  74643. }
  74644. /** @hidden */
  74645. export interface IGLTFTechniqueParameter {
  74646. type: number;
  74647. count?: number;
  74648. semantic?: string;
  74649. node?: string;
  74650. value?: number | boolean | string | Array<any>;
  74651. source?: string;
  74652. babylonValue?: any;
  74653. }
  74654. /** @hidden */
  74655. export interface IGLTFTechniqueCommonProfile {
  74656. lightingModel: string;
  74657. texcoordBindings: Object;
  74658. parameters?: Array<any>;
  74659. }
  74660. /** @hidden */
  74661. export interface IGLTFTechniqueStatesFunctions {
  74662. blendColor?: number[];
  74663. blendEquationSeparate?: number[];
  74664. blendFuncSeparate?: number[];
  74665. colorMask: boolean[];
  74666. cullFace: number[];
  74667. }
  74668. /** @hidden */
  74669. export interface IGLTFTechniqueStates {
  74670. enable: number[];
  74671. functions: IGLTFTechniqueStatesFunctions;
  74672. }
  74673. /** @hidden */
  74674. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74675. parameters: {
  74676. [key: string]: IGLTFTechniqueParameter;
  74677. };
  74678. program: string;
  74679. attributes: {
  74680. [key: string]: string;
  74681. };
  74682. uniforms: {
  74683. [key: string]: string;
  74684. };
  74685. states: IGLTFTechniqueStates;
  74686. }
  74687. /** @hidden */
  74688. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74689. technique?: string;
  74690. values: string[];
  74691. }
  74692. /** @hidden */
  74693. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74694. attributes: {
  74695. [key: string]: string;
  74696. };
  74697. indices: string;
  74698. material: string;
  74699. mode?: number;
  74700. }
  74701. /** @hidden */
  74702. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74703. primitives: IGLTFMeshPrimitive[];
  74704. }
  74705. /** @hidden */
  74706. export interface IGLTFImage extends IGLTFChildRootProperty {
  74707. uri: string;
  74708. }
  74709. /** @hidden */
  74710. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74711. magFilter?: number;
  74712. minFilter?: number;
  74713. wrapS?: number;
  74714. wrapT?: number;
  74715. }
  74716. /** @hidden */
  74717. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74718. sampler: string;
  74719. source: string;
  74720. format?: ETextureFormat;
  74721. internalFormat?: ETextureFormat;
  74722. target?: number;
  74723. type?: number;
  74724. babylonTexture?: Texture;
  74725. }
  74726. /** @hidden */
  74727. export interface IGLTFAmbienLight {
  74728. color?: number[];
  74729. }
  74730. /** @hidden */
  74731. export interface IGLTFDirectionalLight {
  74732. color?: number[];
  74733. }
  74734. /** @hidden */
  74735. export interface IGLTFPointLight {
  74736. color?: number[];
  74737. constantAttenuation?: number;
  74738. linearAttenuation?: number;
  74739. quadraticAttenuation?: number;
  74740. }
  74741. /** @hidden */
  74742. export interface IGLTFSpotLight {
  74743. color?: number[];
  74744. constantAttenuation?: number;
  74745. fallOfAngle?: number;
  74746. fallOffExponent?: number;
  74747. linearAttenuation?: number;
  74748. quadraticAttenuation?: number;
  74749. }
  74750. /** @hidden */
  74751. export interface IGLTFLight extends IGLTFChildRootProperty {
  74752. type: string;
  74753. }
  74754. /** @hidden */
  74755. export interface IGLTFCameraOrthographic {
  74756. xmag: number;
  74757. ymag: number;
  74758. zfar: number;
  74759. znear: number;
  74760. }
  74761. /** @hidden */
  74762. export interface IGLTFCameraPerspective {
  74763. aspectRatio: number;
  74764. yfov: number;
  74765. zfar: number;
  74766. znear: number;
  74767. }
  74768. /** @hidden */
  74769. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74770. type: string;
  74771. }
  74772. /** @hidden */
  74773. export interface IGLTFAnimationChannelTarget {
  74774. id: string;
  74775. path: string;
  74776. }
  74777. /** @hidden */
  74778. export interface IGLTFAnimationChannel {
  74779. sampler: string;
  74780. target: IGLTFAnimationChannelTarget;
  74781. }
  74782. /** @hidden */
  74783. export interface IGLTFAnimationSampler {
  74784. input: string;
  74785. output: string;
  74786. interpolation?: string;
  74787. }
  74788. /** @hidden */
  74789. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74790. channels?: IGLTFAnimationChannel[];
  74791. parameters?: {
  74792. [key: string]: string;
  74793. };
  74794. samplers?: {
  74795. [key: string]: IGLTFAnimationSampler;
  74796. };
  74797. }
  74798. /** @hidden */
  74799. export interface IGLTFNodeInstanceSkin {
  74800. skeletons: string[];
  74801. skin: string;
  74802. meshes: string[];
  74803. }
  74804. /** @hidden */
  74805. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74806. bindShapeMatrix: number[];
  74807. inverseBindMatrices: string;
  74808. jointNames: string[];
  74809. babylonSkeleton?: Skeleton;
  74810. }
  74811. /** @hidden */
  74812. export interface IGLTFNode extends IGLTFChildRootProperty {
  74813. camera?: string;
  74814. children: string[];
  74815. skin?: string;
  74816. jointName?: string;
  74817. light?: string;
  74818. matrix: number[];
  74819. mesh?: string;
  74820. meshes?: string[];
  74821. rotation?: number[];
  74822. scale?: number[];
  74823. translation?: number[];
  74824. babylonNode?: Node;
  74825. }
  74826. /** @hidden */
  74827. export interface IGLTFScene extends IGLTFChildRootProperty {
  74828. nodes: string[];
  74829. }
  74830. /** @hidden */
  74831. export interface IGLTFRuntime {
  74832. extensions: {
  74833. [key: string]: any;
  74834. };
  74835. accessors: {
  74836. [key: string]: IGLTFAccessor;
  74837. };
  74838. buffers: {
  74839. [key: string]: IGLTFBuffer;
  74840. };
  74841. bufferViews: {
  74842. [key: string]: IGLTFBufferView;
  74843. };
  74844. meshes: {
  74845. [key: string]: IGLTFMesh;
  74846. };
  74847. lights: {
  74848. [key: string]: IGLTFLight;
  74849. };
  74850. cameras: {
  74851. [key: string]: IGLTFCamera;
  74852. };
  74853. nodes: {
  74854. [key: string]: IGLTFNode;
  74855. };
  74856. images: {
  74857. [key: string]: IGLTFImage;
  74858. };
  74859. textures: {
  74860. [key: string]: IGLTFTexture;
  74861. };
  74862. shaders: {
  74863. [key: string]: IGLTFShader;
  74864. };
  74865. programs: {
  74866. [key: string]: IGLTFProgram;
  74867. };
  74868. samplers: {
  74869. [key: string]: IGLTFSampler;
  74870. };
  74871. techniques: {
  74872. [key: string]: IGLTFTechnique;
  74873. };
  74874. materials: {
  74875. [key: string]: IGLTFMaterial;
  74876. };
  74877. animations: {
  74878. [key: string]: IGLTFAnimation;
  74879. };
  74880. skins: {
  74881. [key: string]: IGLTFSkins;
  74882. };
  74883. currentScene?: Object;
  74884. scenes: {
  74885. [key: string]: IGLTFScene;
  74886. };
  74887. extensionsUsed: string[];
  74888. extensionsRequired?: string[];
  74889. buffersCount: number;
  74890. shaderscount: number;
  74891. scene: Scene;
  74892. rootUrl: string;
  74893. loadedBufferCount: number;
  74894. loadedBufferViews: {
  74895. [name: string]: ArrayBufferView;
  74896. };
  74897. loadedShaderCount: number;
  74898. importOnlyMeshes: boolean;
  74899. importMeshesNames?: string[];
  74900. dummyNodes: Node[];
  74901. forAssetContainer: boolean;
  74902. }
  74903. /** @hidden */
  74904. export interface INodeToRoot {
  74905. bone: Bone;
  74906. node: IGLTFNode;
  74907. id: string;
  74908. }
  74909. /** @hidden */
  74910. export interface IJointNode {
  74911. node: IGLTFNode;
  74912. id: string;
  74913. }
  74914. }
  74915. declare module BABYLON.GLTF1 {
  74916. /**
  74917. * Utils functions for GLTF
  74918. * @hidden
  74919. */
  74920. export class GLTFUtils {
  74921. /**
  74922. * Sets the given "parameter" matrix
  74923. * @param scene: the Scene object
  74924. * @param source: the source node where to pick the matrix
  74925. * @param parameter: the GLTF technique parameter
  74926. * @param uniformName: the name of the shader's uniform
  74927. * @param shaderMaterial: the shader material
  74928. */
  74929. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74930. /**
  74931. * Sets the given "parameter" matrix
  74932. * @param shaderMaterial: the shader material
  74933. * @param uniform: the name of the shader's uniform
  74934. * @param value: the value of the uniform
  74935. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74936. */
  74937. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74938. /**
  74939. * Returns the wrap mode of the texture
  74940. * @param mode: the mode value
  74941. */
  74942. static GetWrapMode(mode: number): number;
  74943. /**
  74944. * Returns the byte stride giving an accessor
  74945. * @param accessor: the GLTF accessor objet
  74946. */
  74947. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74948. /**
  74949. * Returns the texture filter mode giving a mode value
  74950. * @param mode: the filter mode value
  74951. */
  74952. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74953. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74954. /**
  74955. * Returns a buffer from its accessor
  74956. * @param gltfRuntime: the GLTF runtime
  74957. * @param accessor: the GLTF accessor
  74958. */
  74959. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74960. /**
  74961. * Decodes a buffer view into a string
  74962. * @param view: the buffer view
  74963. */
  74964. static DecodeBufferToText(view: ArrayBufferView): string;
  74965. /**
  74966. * Returns the default material of gltf. Related to
  74967. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74968. * @param scene: the Babylon.js scene
  74969. */
  74970. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74971. private static _DefaultMaterial;
  74972. }
  74973. }
  74974. declare module BABYLON.GLTF1 {
  74975. /**
  74976. * Implementation of the base glTF spec
  74977. * @hidden
  74978. */
  74979. export class GLTFLoaderBase {
  74980. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74981. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74982. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74983. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74984. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74985. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74986. }
  74987. /**
  74988. * glTF V1 Loader
  74989. * @hidden
  74990. */
  74991. export class GLTFLoader implements IGLTFLoader {
  74992. static Extensions: {
  74993. [name: string]: GLTFLoaderExtension;
  74994. };
  74995. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74996. state: Nullable<GLTFLoaderState>;
  74997. dispose(): void;
  74998. private _importMeshAsync;
  74999. /**
  75000. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  75001. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75002. * @param scene the scene the meshes should be added to
  75003. * @param forAssetContainer defines if the entities must be stored in the scene
  75004. * @param data gltf data containing information of the meshes in a loaded file
  75005. * @param rootUrl root url to load from
  75006. * @param onProgress event that fires when loading progress has occured
  75007. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75008. */
  75009. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  75010. private _loadAsync;
  75011. /**
  75012. * Imports all objects from a loaded gltf file and adds them to the scene
  75013. * @param scene the scene the objects should be added to
  75014. * @param data gltf data containing information of the meshes in a loaded file
  75015. * @param rootUrl root url to load from
  75016. * @param onProgress event that fires when loading progress has occured
  75017. * @returns a promise which completes when objects have been loaded to the scene
  75018. */
  75019. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  75020. private _loadShadersAsync;
  75021. private _loadBuffersAsync;
  75022. private _createNodes;
  75023. }
  75024. /** @hidden */
  75025. export abstract class GLTFLoaderExtension {
  75026. private _name;
  75027. constructor(name: string);
  75028. get name(): string;
  75029. /**
  75030. * Defines an override for loading the runtime
  75031. * Return true to stop further extensions from loading the runtime
  75032. */
  75033. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  75034. /**
  75035. * Defines an onverride for creating gltf runtime
  75036. * Return true to stop further extensions from creating the runtime
  75037. */
  75038. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  75039. /**
  75040. * Defines an override for loading buffers
  75041. * Return true to stop further extensions from loading this buffer
  75042. */
  75043. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  75044. /**
  75045. * Defines an override for loading texture buffers
  75046. * Return true to stop further extensions from loading this texture data
  75047. */
  75048. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75049. /**
  75050. * Defines an override for creating textures
  75051. * Return true to stop further extensions from loading this texture
  75052. */
  75053. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  75054. /**
  75055. * Defines an override for loading shader strings
  75056. * Return true to stop further extensions from loading this shader data
  75057. */
  75058. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75059. /**
  75060. * Defines an override for loading materials
  75061. * Return true to stop further extensions from loading this material
  75062. */
  75063. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75064. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  75065. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  75066. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  75067. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  75068. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  75069. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  75070. private static LoadTextureBufferAsync;
  75071. private static CreateTextureAsync;
  75072. private static ApplyExtensions;
  75073. }
  75074. }
  75075. declare module BABYLON.GLTF1 {
  75076. /** @hidden */
  75077. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  75078. private _bin;
  75079. constructor();
  75080. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  75081. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75082. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  75083. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  75084. }
  75085. }
  75086. declare module BABYLON.GLTF1 {
  75087. /** @hidden */
  75088. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  75089. constructor();
  75090. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  75091. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  75092. private _loadTexture;
  75093. }
  75094. }
  75095. declare module BABYLON.GLTF2.Loader {
  75096. /**
  75097. * Loader interface with an index field.
  75098. */
  75099. export interface IArrayItem {
  75100. /**
  75101. * The index of this item in the array.
  75102. */
  75103. index: number;
  75104. }
  75105. /**
  75106. * Loader interface with additional members.
  75107. */
  75108. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75109. /** @hidden */
  75110. _data?: Promise<ArrayBufferView>;
  75111. /** @hidden */
  75112. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75113. }
  75114. /**
  75115. * Loader interface with additional members.
  75116. */
  75117. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75118. }
  75119. /** @hidden */
  75120. export interface _IAnimationSamplerData {
  75121. input: Float32Array;
  75122. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75123. output: Float32Array;
  75124. }
  75125. /**
  75126. * Loader interface with additional members.
  75127. */
  75128. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75129. /** @hidden */
  75130. _data?: Promise<_IAnimationSamplerData>;
  75131. }
  75132. /**
  75133. * Loader interface with additional members.
  75134. */
  75135. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75136. channels: IAnimationChannel[];
  75137. samplers: IAnimationSampler[];
  75138. /** @hidden */
  75139. _babylonAnimationGroup?: AnimationGroup;
  75140. }
  75141. /**
  75142. * Loader interface with additional members.
  75143. */
  75144. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75145. /** @hidden */
  75146. _data?: Promise<ArrayBufferView>;
  75147. }
  75148. /**
  75149. * Loader interface with additional members.
  75150. */
  75151. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75152. /** @hidden */
  75153. _data?: Promise<ArrayBufferView>;
  75154. /** @hidden */
  75155. _babylonBuffer?: Promise<Buffer>;
  75156. }
  75157. /**
  75158. * Loader interface with additional members.
  75159. */
  75160. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75161. }
  75162. /**
  75163. * Loader interface with additional members.
  75164. */
  75165. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75166. /** @hidden */
  75167. _data?: Promise<ArrayBufferView>;
  75168. }
  75169. /**
  75170. * Loader interface with additional members.
  75171. */
  75172. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75173. }
  75174. /**
  75175. * Loader interface with additional members.
  75176. */
  75177. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75178. }
  75179. /**
  75180. * Loader interface with additional members.
  75181. */
  75182. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75183. baseColorTexture?: ITextureInfo;
  75184. metallicRoughnessTexture?: ITextureInfo;
  75185. }
  75186. /**
  75187. * Loader interface with additional members.
  75188. */
  75189. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75190. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75191. normalTexture?: IMaterialNormalTextureInfo;
  75192. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75193. emissiveTexture?: ITextureInfo;
  75194. /** @hidden */
  75195. _data?: {
  75196. [babylonDrawMode: number]: {
  75197. babylonMaterial: Material;
  75198. babylonMeshes: AbstractMesh[];
  75199. promise: Promise<void>;
  75200. };
  75201. };
  75202. }
  75203. /**
  75204. * Loader interface with additional members.
  75205. */
  75206. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75207. primitives: IMeshPrimitive[];
  75208. }
  75209. /**
  75210. * Loader interface with additional members.
  75211. */
  75212. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75213. /** @hidden */
  75214. _instanceData?: {
  75215. babylonSourceMesh: Mesh;
  75216. promise: Promise<any>;
  75217. };
  75218. }
  75219. /**
  75220. * Loader interface with additional members.
  75221. */
  75222. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75223. /**
  75224. * The parent glTF node.
  75225. */
  75226. parent?: INode;
  75227. /** @hidden */
  75228. _babylonTransformNode?: TransformNode;
  75229. /** @hidden */
  75230. _primitiveBabylonMeshes?: AbstractMesh[];
  75231. /** @hidden */
  75232. _babylonBones?: Bone[];
  75233. /** @hidden */
  75234. _numMorphTargets?: number;
  75235. }
  75236. /** @hidden */
  75237. export interface _ISamplerData {
  75238. noMipMaps: boolean;
  75239. samplingMode: number;
  75240. wrapU: number;
  75241. wrapV: number;
  75242. }
  75243. /**
  75244. * Loader interface with additional members.
  75245. */
  75246. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75247. /** @hidden */
  75248. _data?: _ISamplerData;
  75249. }
  75250. /**
  75251. * Loader interface with additional members.
  75252. */
  75253. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75254. }
  75255. /**
  75256. * Loader interface with additional members.
  75257. */
  75258. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75259. /** @hidden */
  75260. _data?: {
  75261. babylonSkeleton: Skeleton;
  75262. promise: Promise<void>;
  75263. };
  75264. }
  75265. /**
  75266. * Loader interface with additional members.
  75267. */
  75268. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75269. }
  75270. /**
  75271. * Loader interface with additional members.
  75272. */
  75273. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75274. }
  75275. /**
  75276. * Loader interface with additional members.
  75277. */
  75278. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75279. accessors?: IAccessor[];
  75280. animations?: IAnimation[];
  75281. buffers?: IBuffer[];
  75282. bufferViews?: IBufferView[];
  75283. cameras?: ICamera[];
  75284. images?: IImage[];
  75285. materials?: IMaterial[];
  75286. meshes?: IMesh[];
  75287. nodes?: INode[];
  75288. samplers?: ISampler[];
  75289. scenes?: IScene[];
  75290. skins?: ISkin[];
  75291. textures?: ITexture[];
  75292. }
  75293. }
  75294. declare module BABYLON.GLTF2 {
  75295. /**
  75296. * Interface for a glTF loader extension.
  75297. */
  75298. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75299. /**
  75300. * Called after the loader state changes to LOADING.
  75301. */
  75302. onLoading?(): void;
  75303. /**
  75304. * Called after the loader state changes to READY.
  75305. */
  75306. onReady?(): void;
  75307. /**
  75308. * Define this method to modify the default behavior when loading scenes.
  75309. * @param context The context when loading the asset
  75310. * @param scene The glTF scene property
  75311. * @returns A promise that resolves when the load is complete or null if not handled
  75312. */
  75313. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75314. /**
  75315. * Define this method to modify the default behavior when loading nodes.
  75316. * @param context The context when loading the asset
  75317. * @param node The glTF node property
  75318. * @param assign A function called synchronously after parsing the glTF properties
  75319. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75320. */
  75321. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75322. /**
  75323. * Define this method to modify the default behavior when loading cameras.
  75324. * @param context The context when loading the asset
  75325. * @param camera The glTF camera property
  75326. * @param assign A function called synchronously after parsing the glTF properties
  75327. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75328. */
  75329. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75330. /**
  75331. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75332. * @param context The context when loading the asset
  75333. * @param primitive The glTF mesh primitive property
  75334. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75335. */
  75336. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75337. /**
  75338. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75339. * @param context The context when loading the asset
  75340. * @param name The mesh name when loading the asset
  75341. * @param node The glTF node when loading the asset
  75342. * @param mesh The glTF mesh when loading the asset
  75343. * @param primitive The glTF mesh primitive property
  75344. * @param assign A function called synchronously after parsing the glTF properties
  75345. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75346. */
  75347. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75348. /**
  75349. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75350. * @param context The context when loading the asset
  75351. * @param material The glTF material property
  75352. * @param assign A function called synchronously after parsing the glTF properties
  75353. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75354. */
  75355. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75356. /**
  75357. * Define this method to modify the default behavior when creating materials.
  75358. * @param context The context when loading the asset
  75359. * @param material The glTF material property
  75360. * @param babylonDrawMode The draw mode for the Babylon material
  75361. * @returns The Babylon material or null if not handled
  75362. */
  75363. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75364. /**
  75365. * Define this method to modify the default behavior when loading material properties.
  75366. * @param context The context when loading the asset
  75367. * @param material The glTF material property
  75368. * @param babylonMaterial The Babylon material
  75369. * @returns A promise that resolves when the load is complete or null if not handled
  75370. */
  75371. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75372. /**
  75373. * Define this method to modify the default behavior when loading texture infos.
  75374. * @param context The context when loading the asset
  75375. * @param textureInfo The glTF texture info property
  75376. * @param assign A function called synchronously after parsing the glTF properties
  75377. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75378. */
  75379. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75380. /**
  75381. * Define this method to modify the default behavior when loading animations.
  75382. * @param context The context when loading the asset
  75383. * @param animation The glTF animation property
  75384. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75385. */
  75386. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75387. /**
  75388. * @hidden Define this method to modify the default behavior when loading skins.
  75389. * @param context The context when loading the asset
  75390. * @param node The glTF node property
  75391. * @param skin The glTF skin property
  75392. * @returns A promise that resolves when the load is complete or null if not handled
  75393. */
  75394. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75395. /**
  75396. * @hidden Define this method to modify the default behavior when loading uris.
  75397. * @param context The context when loading the asset
  75398. * @param property The glTF property associated with the uri
  75399. * @param uri The uri to load
  75400. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75401. */
  75402. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75403. /**
  75404. * Define this method to modify the default behavior when loading buffer views.
  75405. * @param context The context when loading the asset
  75406. * @param bufferView The glTF buffer view property
  75407. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75408. */
  75409. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75410. /**
  75411. * Define this method to modify the default behavior when loading buffers.
  75412. * @param context The context when loading the asset
  75413. * @param buffer The glTF buffer property
  75414. * @param byteOffset The byte offset to load
  75415. * @param byteLength The byte length to load
  75416. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75417. */
  75418. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75419. }
  75420. }
  75421. declare module BABYLON.GLTF2 {
  75422. /**
  75423. * Helper class for working with arrays when loading the glTF asset
  75424. */
  75425. export class ArrayItem {
  75426. /**
  75427. * Gets an item from the given array.
  75428. * @param context The context when loading the asset
  75429. * @param array The array to get the item from
  75430. * @param index The index to the array
  75431. * @returns The array item
  75432. */
  75433. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75434. /**
  75435. * Assign an `index` field to each item of the given array.
  75436. * @param array The array of items
  75437. */
  75438. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75439. }
  75440. /**
  75441. * The glTF 2.0 loader
  75442. */
  75443. export class GLTFLoader implements IGLTFLoader {
  75444. /** @hidden */
  75445. _completePromises: Promise<any>[];
  75446. /** @hidden */
  75447. _forAssetContainer: boolean;
  75448. /** Storage */
  75449. _babylonLights: Light[];
  75450. private _disposed;
  75451. private _parent;
  75452. private _state;
  75453. private _extensions;
  75454. private _rootUrl;
  75455. private _fileName;
  75456. private _uniqueRootUrl;
  75457. private _gltf;
  75458. private _bin;
  75459. private _babylonScene;
  75460. private _rootBabylonMesh;
  75461. private _defaultBabylonMaterialData;
  75462. private _progressCallback?;
  75463. private _requests;
  75464. private static readonly _DefaultSampler;
  75465. private static _RegisteredExtensions;
  75466. /**
  75467. * Registers a loader extension.
  75468. * @param name The name of the loader extension.
  75469. * @param factory The factory function that creates the loader extension.
  75470. */
  75471. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75472. /**
  75473. * Unregisters a loader extension.
  75474. * @param name The name of the loader extension.
  75475. * @returns A boolean indicating whether the extension has been unregistered
  75476. */
  75477. static UnregisterExtension(name: string): boolean;
  75478. /**
  75479. * Gets the loader state.
  75480. */
  75481. get state(): Nullable<GLTFLoaderState>;
  75482. /**
  75483. * The object that represents the glTF JSON.
  75484. */
  75485. get gltf(): IGLTF;
  75486. /**
  75487. * The BIN chunk of a binary glTF.
  75488. */
  75489. get bin(): Nullable<IDataBuffer>;
  75490. /**
  75491. * The parent file loader.
  75492. */
  75493. get parent(): GLTFFileLoader;
  75494. /**
  75495. * The Babylon scene when loading the asset.
  75496. */
  75497. get babylonScene(): Scene;
  75498. /**
  75499. * The root Babylon mesh when loading the asset.
  75500. */
  75501. get rootBabylonMesh(): Mesh;
  75502. /** @hidden */
  75503. constructor(parent: GLTFFileLoader);
  75504. /** @hidden */
  75505. dispose(): void;
  75506. /** @hidden */
  75507. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  75508. /** @hidden */
  75509. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75510. private _loadAsync;
  75511. private _loadData;
  75512. private _setupData;
  75513. private _loadExtensions;
  75514. private _checkExtensions;
  75515. private _setState;
  75516. private _createRootNode;
  75517. /**
  75518. * Loads a glTF scene.
  75519. * @param context The context when loading the asset
  75520. * @param scene The glTF scene property
  75521. * @returns A promise that resolves when the load is complete
  75522. */
  75523. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75524. private _forEachPrimitive;
  75525. private _getMeshes;
  75526. private _getTransformNodes;
  75527. private _getSkeletons;
  75528. private _getAnimationGroups;
  75529. private _startAnimations;
  75530. /**
  75531. * Loads a glTF node.
  75532. * @param context The context when loading the asset
  75533. * @param node The glTF node property
  75534. * @param assign A function called synchronously after parsing the glTF properties
  75535. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75536. */
  75537. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75538. private _loadMeshAsync;
  75539. /**
  75540. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75541. * @param context The context when loading the asset
  75542. * @param name The mesh name when loading the asset
  75543. * @param node The glTF node when loading the asset
  75544. * @param mesh The glTF mesh when loading the asset
  75545. * @param primitive The glTF mesh primitive property
  75546. * @param assign A function called synchronously after parsing the glTF properties
  75547. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75548. */
  75549. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75550. private _loadVertexDataAsync;
  75551. private _createMorphTargets;
  75552. private _loadMorphTargetsAsync;
  75553. private _loadMorphTargetVertexDataAsync;
  75554. private static _LoadTransform;
  75555. private _loadSkinAsync;
  75556. private _loadBones;
  75557. private _loadBone;
  75558. private _loadSkinInverseBindMatricesDataAsync;
  75559. private _updateBoneMatrices;
  75560. private _getNodeMatrix;
  75561. /**
  75562. * Loads a glTF camera.
  75563. * @param context The context when loading the asset
  75564. * @param camera The glTF camera property
  75565. * @param assign A function called synchronously after parsing the glTF properties
  75566. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75567. */
  75568. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75569. private _loadAnimationsAsync;
  75570. /**
  75571. * Loads a glTF animation.
  75572. * @param context The context when loading the asset
  75573. * @param animation The glTF animation property
  75574. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75575. */
  75576. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75577. /**
  75578. * @hidden Loads a glTF animation channel.
  75579. * @param context The context when loading the asset
  75580. * @param animationContext The context of the animation when loading the asset
  75581. * @param animation The glTF animation property
  75582. * @param channel The glTF animation channel property
  75583. * @param babylonAnimationGroup The babylon animation group property
  75584. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75585. * @returns A void promise when the channel load is complete
  75586. */
  75587. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75588. private _loadAnimationSamplerAsync;
  75589. private _loadBufferAsync;
  75590. /**
  75591. * Loads a glTF buffer view.
  75592. * @param context The context when loading the asset
  75593. * @param bufferView The glTF buffer view property
  75594. * @returns A promise that resolves with the loaded data when the load is complete
  75595. */
  75596. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75597. private _loadAccessorAsync;
  75598. private _loadFloatAccessorAsync;
  75599. private _loadIndicesAccessorAsync;
  75600. private _loadVertexBufferViewAsync;
  75601. private _loadVertexAccessorAsync;
  75602. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75603. /** @hidden */
  75604. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75605. private _createDefaultMaterial;
  75606. /**
  75607. * Creates a Babylon material from a glTF material.
  75608. * @param context The context when loading the asset
  75609. * @param material The glTF material property
  75610. * @param babylonDrawMode The draw mode for the Babylon material
  75611. * @returns The Babylon material
  75612. */
  75613. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75614. /**
  75615. * Loads properties from a glTF material into a Babylon material.
  75616. * @param context The context when loading the asset
  75617. * @param material The glTF material property
  75618. * @param babylonMaterial The Babylon material
  75619. * @returns A promise that resolves when the load is complete
  75620. */
  75621. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75622. /**
  75623. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75624. * @param context The context when loading the asset
  75625. * @param material The glTF material property
  75626. * @param babylonMaterial The Babylon material
  75627. * @returns A promise that resolves when the load is complete
  75628. */
  75629. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75630. /**
  75631. * Loads the alpha properties from a glTF material into a Babylon material.
  75632. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75633. * @param context The context when loading the asset
  75634. * @param material The glTF material property
  75635. * @param babylonMaterial The Babylon material
  75636. */
  75637. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75638. /**
  75639. * Loads a glTF texture info.
  75640. * @param context The context when loading the asset
  75641. * @param textureInfo The glTF texture info property
  75642. * @param assign A function called synchronously after parsing the glTF properties
  75643. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75644. */
  75645. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75646. private _loadTextureAsync;
  75647. private _loadSampler;
  75648. /**
  75649. * Loads a glTF image.
  75650. * @param context The context when loading the asset
  75651. * @param image The glTF image property
  75652. * @returns A promise that resolves with the loaded data when the load is complete
  75653. */
  75654. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75655. /**
  75656. * Loads a glTF uri.
  75657. * @param context The context when loading the asset
  75658. * @param property The glTF property associated with the uri
  75659. * @param uri The base64 or relative uri
  75660. * @returns A promise that resolves with the loaded data when the load is complete
  75661. */
  75662. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75663. private _onProgress;
  75664. /**
  75665. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75666. * @param babylonObject the Babylon object with metadata
  75667. * @param pointer the JSON pointer
  75668. */
  75669. static AddPointerMetadata(babylonObject: {
  75670. metadata: any;
  75671. }, pointer: string): void;
  75672. private static _GetTextureWrapMode;
  75673. private static _GetTextureSamplingMode;
  75674. private static _GetTypedArrayConstructor;
  75675. private static _GetTypedArray;
  75676. private static _GetNumComponents;
  75677. private static _ValidateUri;
  75678. private static _GetDrawMode;
  75679. private _compileMaterialsAsync;
  75680. private _compileShadowGeneratorsAsync;
  75681. private _forEachExtensions;
  75682. private _applyExtensions;
  75683. private _extensionsOnLoading;
  75684. private _extensionsOnReady;
  75685. private _extensionsLoadSceneAsync;
  75686. private _extensionsLoadNodeAsync;
  75687. private _extensionsLoadCameraAsync;
  75688. private _extensionsLoadVertexDataAsync;
  75689. private _extensionsLoadMeshPrimitiveAsync;
  75690. private _extensionsLoadMaterialAsync;
  75691. private _extensionsCreateMaterial;
  75692. private _extensionsLoadMaterialPropertiesAsync;
  75693. private _extensionsLoadTextureInfoAsync;
  75694. private _extensionsLoadAnimationAsync;
  75695. private _extensionsLoadSkinAsync;
  75696. private _extensionsLoadUriAsync;
  75697. private _extensionsLoadBufferViewAsync;
  75698. private _extensionsLoadBufferAsync;
  75699. /**
  75700. * Helper method called by a loader extension to load an glTF extension.
  75701. * @param context The context when loading the asset
  75702. * @param property The glTF property to load the extension from
  75703. * @param extensionName The name of the extension to load
  75704. * @param actionAsync The action to run
  75705. * @returns The promise returned by actionAsync or null if the extension does not exist
  75706. */
  75707. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75708. /**
  75709. * Helper method called by a loader extension to load a glTF extra.
  75710. * @param context The context when loading the asset
  75711. * @param property The glTF property to load the extra from
  75712. * @param extensionName The name of the extension to load
  75713. * @param actionAsync The action to run
  75714. * @returns The promise returned by actionAsync or null if the extra does not exist
  75715. */
  75716. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75717. /**
  75718. * Checks for presence of an extension.
  75719. * @param name The name of the extension to check
  75720. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75721. */
  75722. isExtensionUsed(name: string): boolean;
  75723. /**
  75724. * Increments the indentation level and logs a message.
  75725. * @param message The message to log
  75726. */
  75727. logOpen(message: string): void;
  75728. /**
  75729. * Decrements the indentation level.
  75730. */
  75731. logClose(): void;
  75732. /**
  75733. * Logs a message
  75734. * @param message The message to log
  75735. */
  75736. log(message: string): void;
  75737. /**
  75738. * Starts a performance counter.
  75739. * @param counterName The name of the performance counter
  75740. */
  75741. startPerformanceCounter(counterName: string): void;
  75742. /**
  75743. * Ends a performance counter.
  75744. * @param counterName The name of the performance counter
  75745. */
  75746. endPerformanceCounter(counterName: string): void;
  75747. }
  75748. }
  75749. declare module BABYLON.GLTF2.Loader.Extensions {
  75750. /**
  75751. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75752. */
  75753. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75754. /**
  75755. * The name of this extension.
  75756. */
  75757. readonly name: string;
  75758. /**
  75759. * Defines whether this extension is enabled.
  75760. */
  75761. enabled: boolean;
  75762. private _loader;
  75763. private _lights?;
  75764. /** @hidden */
  75765. constructor(loader: GLTFLoader);
  75766. /** @hidden */
  75767. dispose(): void;
  75768. /** @hidden */
  75769. onLoading(): void;
  75770. /** @hidden */
  75771. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75772. private _loadLightAsync;
  75773. }
  75774. }
  75775. declare module BABYLON.GLTF2.Loader.Extensions {
  75776. /**
  75777. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75778. */
  75779. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75780. /**
  75781. * The name of this extension.
  75782. */
  75783. readonly name: string;
  75784. /**
  75785. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75786. */
  75787. dracoCompression?: DracoCompression;
  75788. /**
  75789. * Defines whether this extension is enabled.
  75790. */
  75791. enabled: boolean;
  75792. private _loader;
  75793. /** @hidden */
  75794. constructor(loader: GLTFLoader);
  75795. /** @hidden */
  75796. dispose(): void;
  75797. /** @hidden */
  75798. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75799. }
  75800. }
  75801. declare module BABYLON.GLTF2.Loader.Extensions {
  75802. /**
  75803. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75804. */
  75805. export class KHR_lights implements IGLTFLoaderExtension {
  75806. /**
  75807. * The name of this extension.
  75808. */
  75809. readonly name: string;
  75810. /**
  75811. * Defines whether this extension is enabled.
  75812. */
  75813. enabled: boolean;
  75814. private _loader;
  75815. private _lights?;
  75816. /** @hidden */
  75817. constructor(loader: GLTFLoader);
  75818. /** @hidden */
  75819. dispose(): void;
  75820. /** @hidden */
  75821. onLoading(): void;
  75822. /** @hidden */
  75823. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75824. }
  75825. }
  75826. declare module BABYLON.GLTF2.Loader.Extensions {
  75827. /**
  75828. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75829. */
  75830. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75831. /**
  75832. * The name of this extension.
  75833. */
  75834. readonly name: string;
  75835. /**
  75836. * Defines whether this extension is enabled.
  75837. */
  75838. enabled: boolean;
  75839. /**
  75840. * Defines a number that determines the order the extensions are applied.
  75841. */
  75842. order: number;
  75843. private _loader;
  75844. /** @hidden */
  75845. constructor(loader: GLTFLoader);
  75846. /** @hidden */
  75847. dispose(): void;
  75848. /** @hidden */
  75849. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75850. private _loadSpecularGlossinessPropertiesAsync;
  75851. }
  75852. }
  75853. declare module BABYLON.GLTF2.Loader.Extensions {
  75854. /**
  75855. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75856. */
  75857. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75858. /**
  75859. * The name of this extension.
  75860. */
  75861. readonly name: string;
  75862. /**
  75863. * Defines whether this extension is enabled.
  75864. */
  75865. enabled: boolean;
  75866. /**
  75867. * Defines a number that determines the order the extensions are applied.
  75868. */
  75869. order: number;
  75870. private _loader;
  75871. /** @hidden */
  75872. constructor(loader: GLTFLoader);
  75873. /** @hidden */
  75874. dispose(): void;
  75875. /** @hidden */
  75876. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75877. private _loadUnlitPropertiesAsync;
  75878. }
  75879. }
  75880. declare module BABYLON.GLTF2.Loader.Extensions {
  75881. /**
  75882. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75883. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75884. * !!! Experimental Extension Subject to Changes !!!
  75885. */
  75886. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75887. /**
  75888. * The name of this extension.
  75889. */
  75890. readonly name: string;
  75891. /**
  75892. * Defines whether this extension is enabled.
  75893. */
  75894. enabled: boolean;
  75895. /**
  75896. * Defines a number that determines the order the extensions are applied.
  75897. */
  75898. order: number;
  75899. private _loader;
  75900. /** @hidden */
  75901. constructor(loader: GLTFLoader);
  75902. /** @hidden */
  75903. dispose(): void;
  75904. /** @hidden */
  75905. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75906. private _loadClearCoatPropertiesAsync;
  75907. }
  75908. }
  75909. declare module BABYLON.GLTF2.Loader.Extensions {
  75910. /**
  75911. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75912. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75913. * !!! Experimental Extension Subject to Changes !!!
  75914. */
  75915. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75916. /**
  75917. * The name of this extension.
  75918. */
  75919. readonly name: string;
  75920. /**
  75921. * Defines whether this extension is enabled.
  75922. */
  75923. enabled: boolean;
  75924. /**
  75925. * Defines a number that determines the order the extensions are applied.
  75926. */
  75927. order: number;
  75928. private _loader;
  75929. /** @hidden */
  75930. constructor(loader: GLTFLoader);
  75931. /** @hidden */
  75932. dispose(): void;
  75933. /** @hidden */
  75934. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75935. private _loadSheenPropertiesAsync;
  75936. }
  75937. }
  75938. declare module BABYLON.GLTF2.Loader.Extensions {
  75939. /**
  75940. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75941. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75942. * !!! Experimental Extension Subject to Changes !!!
  75943. */
  75944. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75945. /**
  75946. * The name of this extension.
  75947. */
  75948. readonly name: string;
  75949. /**
  75950. * Defines whether this extension is enabled.
  75951. */
  75952. enabled: boolean;
  75953. /**
  75954. * Defines a number that determines the order the extensions are applied.
  75955. */
  75956. order: number;
  75957. private _loader;
  75958. /** @hidden */
  75959. constructor(loader: GLTFLoader);
  75960. /** @hidden */
  75961. dispose(): void;
  75962. /** @hidden */
  75963. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75964. private _loadSpecularPropertiesAsync;
  75965. }
  75966. }
  75967. declare module BABYLON.GLTF2.Loader.Extensions {
  75968. /**
  75969. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75970. */
  75971. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75972. /**
  75973. * The name of this extension.
  75974. */
  75975. readonly name: string;
  75976. /**
  75977. * Defines whether this extension is enabled.
  75978. */
  75979. enabled: boolean;
  75980. /** @hidden */
  75981. constructor(loader: GLTFLoader);
  75982. /** @hidden */
  75983. dispose(): void;
  75984. }
  75985. }
  75986. declare module BABYLON.GLTF2.Loader.Extensions {
  75987. /**
  75988. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75989. */
  75990. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75991. /**
  75992. * The name of this extension.
  75993. */
  75994. readonly name: string;
  75995. /**
  75996. * Defines whether this extension is enabled.
  75997. */
  75998. enabled: boolean;
  75999. private _loader;
  76000. /** @hidden */
  76001. constructor(loader: GLTFLoader);
  76002. /** @hidden */
  76003. dispose(): void;
  76004. /** @hidden */
  76005. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  76006. }
  76007. }
  76008. declare module BABYLON.GLTF2.Loader.Extensions {
  76009. /**
  76010. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  76011. */
  76012. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  76013. /**
  76014. * The name of this extension.
  76015. */
  76016. readonly name: string;
  76017. /**
  76018. * Defines whether this extension is enabled.
  76019. */
  76020. enabled: boolean;
  76021. private _loader;
  76022. private _clips;
  76023. private _emitters;
  76024. /** @hidden */
  76025. constructor(loader: GLTFLoader);
  76026. /** @hidden */
  76027. dispose(): void;
  76028. /** @hidden */
  76029. onLoading(): void;
  76030. /** @hidden */
  76031. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76032. /** @hidden */
  76033. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76034. /** @hidden */
  76035. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  76036. private _loadClipAsync;
  76037. private _loadEmitterAsync;
  76038. private _getEventAction;
  76039. private _loadAnimationEventAsync;
  76040. }
  76041. }
  76042. declare module BABYLON.GLTF2.Loader.Extensions {
  76043. /**
  76044. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  76045. */
  76046. export class MSFT_lod implements IGLTFLoaderExtension {
  76047. /**
  76048. * The name of this extension.
  76049. */
  76050. readonly name: string;
  76051. /**
  76052. * Defines whether this extension is enabled.
  76053. */
  76054. enabled: boolean;
  76055. /**
  76056. * Defines a number that determines the order the extensions are applied.
  76057. */
  76058. order: number;
  76059. /**
  76060. * Maximum number of LODs to load, starting from the lowest LOD.
  76061. */
  76062. maxLODsToLoad: number;
  76063. /**
  76064. * Observable raised when all node LODs of one level are loaded.
  76065. * The event data is the index of the loaded LOD starting from zero.
  76066. * Dispose the loader to cancel the loading of the next level of LODs.
  76067. */
  76068. onNodeLODsLoadedObservable: Observable<number>;
  76069. /**
  76070. * Observable raised when all material LODs of one level are loaded.
  76071. * The event data is the index of the loaded LOD starting from zero.
  76072. * Dispose the loader to cancel the loading of the next level of LODs.
  76073. */
  76074. onMaterialLODsLoadedObservable: Observable<number>;
  76075. private _loader;
  76076. private _nodeIndexLOD;
  76077. private _nodeSignalLODs;
  76078. private _nodePromiseLODs;
  76079. private _materialIndexLOD;
  76080. private _materialSignalLODs;
  76081. private _materialPromiseLODs;
  76082. private _indexLOD;
  76083. private _bufferLODs;
  76084. /** @hidden */
  76085. constructor(loader: GLTFLoader);
  76086. /** @hidden */
  76087. dispose(): void;
  76088. /** @hidden */
  76089. onReady(): void;
  76090. /** @hidden */
  76091. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  76092. /** @hidden */
  76093. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76094. /** @hidden */
  76095. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  76096. /** @hidden */
  76097. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  76098. /** @hidden */
  76099. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  76100. private _loadBufferLOD;
  76101. /**
  76102. * Gets an array of LOD properties from lowest to highest.
  76103. */
  76104. private _getLODs;
  76105. private _disposeTransformNode;
  76106. private _disposeMaterials;
  76107. }
  76108. }
  76109. declare module BABYLON.GLTF2.Loader.Extensions {
  76110. /** @hidden */
  76111. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76112. readonly name: string;
  76113. enabled: boolean;
  76114. private _loader;
  76115. constructor(loader: GLTFLoader);
  76116. dispose(): void;
  76117. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76118. }
  76119. }
  76120. declare module BABYLON.GLTF2.Loader.Extensions {
  76121. /** @hidden */
  76122. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76123. readonly name: string;
  76124. enabled: boolean;
  76125. private _loader;
  76126. constructor(loader: GLTFLoader);
  76127. dispose(): void;
  76128. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76129. }
  76130. }
  76131. declare module BABYLON.GLTF2.Loader.Extensions {
  76132. /**
  76133. * Store glTF extras (if present) in BJS objects' metadata
  76134. */
  76135. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76136. /**
  76137. * The name of this extension.
  76138. */
  76139. readonly name: string;
  76140. /**
  76141. * Defines whether this extension is enabled.
  76142. */
  76143. enabled: boolean;
  76144. private _loader;
  76145. private _assignExtras;
  76146. /** @hidden */
  76147. constructor(loader: GLTFLoader);
  76148. /** @hidden */
  76149. dispose(): void;
  76150. /** @hidden */
  76151. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76152. /** @hidden */
  76153. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76154. /** @hidden */
  76155. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76156. }
  76157. }
  76158. declare module BABYLON {
  76159. /**
  76160. * Class reading and parsing the MTL file bundled with the obj file.
  76161. */
  76162. export class MTLFileLoader {
  76163. /**
  76164. * Invert Y-Axis of referenced textures on load
  76165. */
  76166. static INVERT_TEXTURE_Y: boolean;
  76167. /**
  76168. * All material loaded from the mtl will be set here
  76169. */
  76170. materials: StandardMaterial[];
  76171. /**
  76172. * This function will read the mtl file and create each material described inside
  76173. * This function could be improve by adding :
  76174. * -some component missing (Ni, Tf...)
  76175. * -including the specific options available
  76176. *
  76177. * @param scene defines the scene the material will be created in
  76178. * @param data defines the mtl data to parse
  76179. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76180. * @param forAssetContainer defines if the material should be registered in the scene
  76181. */
  76182. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  76183. /**
  76184. * Gets the texture for the material.
  76185. *
  76186. * If the material is imported from input file,
  76187. * We sanitize the url to ensure it takes the textre from aside the material.
  76188. *
  76189. * @param rootUrl The root url to load from
  76190. * @param value The value stored in the mtl
  76191. * @return The Texture
  76192. */
  76193. private static _getTexture;
  76194. }
  76195. }
  76196. declare module BABYLON {
  76197. /**
  76198. * Options for loading OBJ/MTL files
  76199. */
  76200. type MeshLoadOptions = {
  76201. /**
  76202. * Defines if UVs are optimized by default during load.
  76203. */
  76204. OptimizeWithUV: boolean;
  76205. /**
  76206. * Defines custom scaling of UV coordinates of loaded meshes.
  76207. */
  76208. UVScaling: Vector2;
  76209. /**
  76210. * Invert model on y-axis (does a model scaling inversion)
  76211. */
  76212. InvertY: boolean;
  76213. /**
  76214. * Invert Y-Axis of referenced textures on load
  76215. */
  76216. InvertTextureY: boolean;
  76217. /**
  76218. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76219. */
  76220. ImportVertexColors: boolean;
  76221. /**
  76222. * Compute the normals for the model, even if normals are present in the file.
  76223. */
  76224. ComputeNormals: boolean;
  76225. /**
  76226. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76227. */
  76228. SkipMaterials: boolean;
  76229. /**
  76230. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76231. */
  76232. MaterialLoadingFailsSilently: boolean;
  76233. };
  76234. /**
  76235. * OBJ file type loader.
  76236. * This is a babylon scene loader plugin.
  76237. */
  76238. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76239. /**
  76240. * Defines if UVs are optimized by default during load.
  76241. */
  76242. static OPTIMIZE_WITH_UV: boolean;
  76243. /**
  76244. * Invert model on y-axis (does a model scaling inversion)
  76245. */
  76246. static INVERT_Y: boolean;
  76247. /**
  76248. * Invert Y-Axis of referenced textures on load
  76249. */
  76250. static get INVERT_TEXTURE_Y(): boolean;
  76251. static set INVERT_TEXTURE_Y(value: boolean);
  76252. /**
  76253. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76254. */
  76255. static IMPORT_VERTEX_COLORS: boolean;
  76256. /**
  76257. * Compute the normals for the model, even if normals are present in the file.
  76258. */
  76259. static COMPUTE_NORMALS: boolean;
  76260. /**
  76261. * Defines custom scaling of UV coordinates of loaded meshes.
  76262. */
  76263. static UV_SCALING: Vector2;
  76264. /**
  76265. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76266. */
  76267. static SKIP_MATERIALS: boolean;
  76268. /**
  76269. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76270. *
  76271. * Defaults to true for backwards compatibility.
  76272. */
  76273. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76274. /**
  76275. * Defines the name of the plugin.
  76276. */
  76277. name: string;
  76278. /**
  76279. * Defines the extension the plugin is able to load.
  76280. */
  76281. extensions: string;
  76282. /** @hidden */
  76283. obj: RegExp;
  76284. /** @hidden */
  76285. group: RegExp;
  76286. /** @hidden */
  76287. mtllib: RegExp;
  76288. /** @hidden */
  76289. usemtl: RegExp;
  76290. /** @hidden */
  76291. smooth: RegExp;
  76292. /** @hidden */
  76293. vertexPattern: RegExp;
  76294. /** @hidden */
  76295. normalPattern: RegExp;
  76296. /** @hidden */
  76297. uvPattern: RegExp;
  76298. /** @hidden */
  76299. facePattern1: RegExp;
  76300. /** @hidden */
  76301. facePattern2: RegExp;
  76302. /** @hidden */
  76303. facePattern3: RegExp;
  76304. /** @hidden */
  76305. facePattern4: RegExp;
  76306. /** @hidden */
  76307. facePattern5: RegExp;
  76308. private _forAssetContainer;
  76309. private _meshLoadOptions;
  76310. /**
  76311. * Creates loader for .OBJ files
  76312. *
  76313. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76314. */
  76315. constructor(meshLoadOptions?: MeshLoadOptions);
  76316. private static get currentMeshLoadOptions();
  76317. /**
  76318. * Calls synchronously the MTL file attached to this obj.
  76319. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76320. * Without this function materials are not displayed in the first frame (but displayed after).
  76321. * In consequence it is impossible to get material information in your HTML file
  76322. *
  76323. * @param url The URL of the MTL file
  76324. * @param rootUrl
  76325. * @param onSuccess Callback function to be called when the MTL file is loaded
  76326. * @private
  76327. */
  76328. private _loadMTL;
  76329. /**
  76330. * Instantiates a OBJ file loader plugin.
  76331. * @returns the created plugin
  76332. */
  76333. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76334. /**
  76335. * If the data string can be loaded directly.
  76336. *
  76337. * @param data string containing the file data
  76338. * @returns if the data can be loaded directly
  76339. */
  76340. canDirectLoad(data: string): boolean;
  76341. /**
  76342. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76343. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76344. * @param scene the scene the meshes should be added to
  76345. * @param data the OBJ data to load
  76346. * @param rootUrl root url to load from
  76347. * @param onProgress event that fires when loading progress has occured
  76348. * @param fileName Defines the name of the file to load
  76349. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76350. */
  76351. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76352. meshes: AbstractMesh[];
  76353. particleSystems: IParticleSystem[];
  76354. skeletons: Skeleton[];
  76355. animationGroups: AnimationGroup[];
  76356. }>;
  76357. /**
  76358. * Imports all objects from the loaded OBJ data and adds them to the scene
  76359. * @param scene the scene the objects should be added to
  76360. * @param data the OBJ data to load
  76361. * @param rootUrl root url to load from
  76362. * @param onProgress event that fires when loading progress has occured
  76363. * @param fileName Defines the name of the file to load
  76364. * @returns a promise which completes when objects have been loaded to the scene
  76365. */
  76366. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76367. /**
  76368. * Load into an asset container.
  76369. * @param scene The scene to load into
  76370. * @param data The data to import
  76371. * @param rootUrl The root url for scene and resources
  76372. * @param onProgress The callback when the load progresses
  76373. * @param fileName Defines the name of the file to load
  76374. * @returns The loaded asset container
  76375. */
  76376. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76377. /**
  76378. * Read the OBJ file and create an Array of meshes.
  76379. * Each mesh contains all information given by the OBJ and the MTL file.
  76380. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76381. *
  76382. * @param meshesNames
  76383. * @param scene Scene The scene where are displayed the data
  76384. * @param data String The content of the obj file
  76385. * @param rootUrl String The path to the folder
  76386. * @returns Array<AbstractMesh>
  76387. * @private
  76388. */
  76389. private _parseSolid;
  76390. }
  76391. }
  76392. declare module BABYLON {
  76393. /**
  76394. * STL file type loader.
  76395. * This is a babylon scene loader plugin.
  76396. */
  76397. export class STLFileLoader implements ISceneLoaderPlugin {
  76398. /** @hidden */
  76399. solidPattern: RegExp;
  76400. /** @hidden */
  76401. facetsPattern: RegExp;
  76402. /** @hidden */
  76403. normalPattern: RegExp;
  76404. /** @hidden */
  76405. vertexPattern: RegExp;
  76406. /**
  76407. * Defines the name of the plugin.
  76408. */
  76409. name: string;
  76410. /**
  76411. * Defines the extensions the stl loader is able to load.
  76412. * force data to come in as an ArrayBuffer
  76413. * we'll convert to string if it looks like it's an ASCII .stl
  76414. */
  76415. extensions: ISceneLoaderPluginExtensions;
  76416. /**
  76417. * Import meshes into a scene.
  76418. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76419. * @param scene The scene to import into
  76420. * @param data The data to import
  76421. * @param rootUrl The root url for scene and resources
  76422. * @param meshes The meshes array to import into
  76423. * @param particleSystems The particle systems array to import into
  76424. * @param skeletons The skeletons array to import into
  76425. * @param onError The callback when import fails
  76426. * @returns True if successful or false otherwise
  76427. */
  76428. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76429. /**
  76430. * Load into a scene.
  76431. * @param scene The scene to load into
  76432. * @param data The data to import
  76433. * @param rootUrl The root url for scene and resources
  76434. * @param onError The callback when import fails
  76435. * @returns true if successful or false otherwise
  76436. */
  76437. load(scene: Scene, data: any, rootUrl: string): boolean;
  76438. /**
  76439. * Load into an asset container.
  76440. * @param scene The scene to load into
  76441. * @param data The data to import
  76442. * @param rootUrl The root url for scene and resources
  76443. * @param onError The callback when import fails
  76444. * @returns The loaded asset container
  76445. */
  76446. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76447. private _isBinary;
  76448. private _parseBinary;
  76449. private _parseASCII;
  76450. }
  76451. }
  76452. declare module BABYLON {
  76453. /**
  76454. * Class for generating OBJ data from a Babylon scene.
  76455. */
  76456. export class OBJExport {
  76457. /**
  76458. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76459. * @param mesh defines the list of meshes to serialize
  76460. * @param materials defines if materials should be exported
  76461. * @param matlibname defines the name of the associated mtl file
  76462. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76463. * @returns the OBJ content
  76464. */
  76465. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76466. /**
  76467. * Exports the material(s) of a mesh in .MTL file format (text)
  76468. * @param mesh defines the mesh to extract the material from
  76469. * @returns the mtl content
  76470. */
  76471. static MTL(mesh: Mesh): string;
  76472. }
  76473. }
  76474. declare module BABYLON {
  76475. /** @hidden */
  76476. export var __IGLTFExporterExtension: number;
  76477. /**
  76478. * Interface for extending the exporter
  76479. * @hidden
  76480. */
  76481. export interface IGLTFExporterExtension {
  76482. /**
  76483. * The name of this extension
  76484. */
  76485. readonly name: string;
  76486. /**
  76487. * Defines whether this extension is enabled
  76488. */
  76489. enabled: boolean;
  76490. /**
  76491. * Defines whether this extension is required
  76492. */
  76493. required: boolean;
  76494. }
  76495. }
  76496. declare module BABYLON.GLTF2.Exporter {
  76497. /** @hidden */
  76498. export var __IGLTFExporterExtensionV2: number;
  76499. /**
  76500. * Interface for a glTF exporter extension
  76501. * @hidden
  76502. */
  76503. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76504. /**
  76505. * Define this method to modify the default behavior before exporting a texture
  76506. * @param context The context when loading the asset
  76507. * @param babylonTexture The Babylon.js texture
  76508. * @param mimeType The mime-type of the generated image
  76509. * @returns A promise that resolves with the exported texture
  76510. */
  76511. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76512. /**
  76513. * Define this method to get notified when a texture info is created
  76514. * @param context The context when loading the asset
  76515. * @param textureInfo The glTF texture info
  76516. * @param babylonTexture The Babylon.js texture
  76517. */
  76518. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76519. /**
  76520. * Define this method to modify the default behavior when exporting texture info
  76521. * @param context The context when loading the asset
  76522. * @param meshPrimitive glTF mesh primitive
  76523. * @param babylonSubMesh Babylon submesh
  76524. * @param binaryWriter glTF serializer binary writer instance
  76525. * @returns nullable IMeshPrimitive promise
  76526. */
  76527. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76528. /**
  76529. * Define this method to modify the default behavior when exporting a node
  76530. * @param context The context when exporting the node
  76531. * @param node glTF node
  76532. * @param babylonNode BabylonJS node
  76533. * @returns nullable INode promise
  76534. */
  76535. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76536. /**
  76537. * Define this method to modify the default behavior when exporting a material
  76538. * @param material glTF material
  76539. * @param babylonMaterial BabylonJS material
  76540. * @returns nullable IMaterial promise
  76541. */
  76542. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76543. /**
  76544. * Define this method to return additional textures to export from a material
  76545. * @param material glTF material
  76546. * @param babylonMaterial BabylonJS material
  76547. * @returns List of textures
  76548. */
  76549. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76550. /** Gets a boolean indicating that this extension was used */
  76551. wasUsed: boolean;
  76552. /** Gets a boolean indicating that this extension is required for the file to work */
  76553. required: boolean;
  76554. /**
  76555. * Called after the exporter state changes to EXPORTING
  76556. */
  76557. onExporting?(): void;
  76558. }
  76559. }
  76560. declare module BABYLON.GLTF2.Exporter {
  76561. /**
  76562. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76563. * @hidden
  76564. */
  76565. export class _GLTFMaterialExporter {
  76566. /**
  76567. * Represents the dielectric specular values for R, G and B
  76568. */
  76569. private static readonly _DielectricSpecular;
  76570. /**
  76571. * Allows the maximum specular power to be defined for material calculations
  76572. */
  76573. private static readonly _MaxSpecularPower;
  76574. /**
  76575. * Mapping to store textures
  76576. */
  76577. private _textureMap;
  76578. /**
  76579. * Numeric tolerance value
  76580. */
  76581. private static readonly _Epsilon;
  76582. /**
  76583. * Reference to the glTF Exporter
  76584. */
  76585. private _exporter;
  76586. constructor(exporter: _Exporter);
  76587. /**
  76588. * Specifies if two colors are approximately equal in value
  76589. * @param color1 first color to compare to
  76590. * @param color2 second color to compare to
  76591. * @param epsilon threshold value
  76592. */
  76593. private static FuzzyEquals;
  76594. /**
  76595. * Gets the materials from a Babylon scene and converts them to glTF materials
  76596. * @param scene babylonjs scene
  76597. * @param mimeType texture mime type
  76598. * @param images array of images
  76599. * @param textures array of textures
  76600. * @param materials array of materials
  76601. * @param imageData mapping of texture names to base64 textures
  76602. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76603. */
  76604. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76605. /**
  76606. * Makes a copy of the glTF material without the texture parameters
  76607. * @param originalMaterial original glTF material
  76608. * @returns glTF material without texture parameters
  76609. */
  76610. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76611. /**
  76612. * Specifies if the material has any texture parameters present
  76613. * @param material glTF Material
  76614. * @returns boolean specifying if texture parameters are present
  76615. */
  76616. _hasTexturesPresent(material: IMaterial): boolean;
  76617. /**
  76618. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76619. * @param babylonStandardMaterial
  76620. * @returns glTF Metallic Roughness Material representation
  76621. */
  76622. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76623. /**
  76624. * Computes the metallic factor
  76625. * @param diffuse diffused value
  76626. * @param specular specular value
  76627. * @param oneMinusSpecularStrength one minus the specular strength
  76628. * @returns metallic value
  76629. */
  76630. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76631. /**
  76632. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76633. * @param glTFMaterial glTF material
  76634. * @param babylonMaterial Babylon material
  76635. */
  76636. private static _SetAlphaMode;
  76637. /**
  76638. * Converts a Babylon Standard Material to a glTF Material
  76639. * @param babylonStandardMaterial BJS Standard Material
  76640. * @param mimeType mime type to use for the textures
  76641. * @param images array of glTF image interfaces
  76642. * @param textures array of glTF texture interfaces
  76643. * @param materials array of glTF material interfaces
  76644. * @param imageData map of image file name to data
  76645. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76646. */
  76647. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76648. private _finishMaterial;
  76649. /**
  76650. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76651. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76652. * @param mimeType mime type to use for the textures
  76653. * @param images array of glTF image interfaces
  76654. * @param textures array of glTF texture interfaces
  76655. * @param materials array of glTF material interfaces
  76656. * @param imageData map of image file name to data
  76657. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76658. */
  76659. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76660. /**
  76661. * Converts an image typed array buffer to a base64 image
  76662. * @param buffer typed array buffer
  76663. * @param width width of the image
  76664. * @param height height of the image
  76665. * @param mimeType mimetype of the image
  76666. * @returns base64 image string
  76667. */
  76668. private _createBase64FromCanvasAsync;
  76669. /**
  76670. * Generates a white texture based on the specified width and height
  76671. * @param width width of the texture in pixels
  76672. * @param height height of the texture in pixels
  76673. * @param scene babylonjs scene
  76674. * @returns white texture
  76675. */
  76676. private _createWhiteTexture;
  76677. /**
  76678. * 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
  76679. * @param texture1 first texture to resize
  76680. * @param texture2 second texture to resize
  76681. * @param scene babylonjs scene
  76682. * @returns resized textures or null
  76683. */
  76684. private _resizeTexturesToSameDimensions;
  76685. /**
  76686. * Converts an array of pixels to a Float32Array
  76687. * Throws an error if the pixel format is not supported
  76688. * @param pixels - array buffer containing pixel values
  76689. * @returns Float32 of pixels
  76690. */
  76691. private _convertPixelArrayToFloat32;
  76692. /**
  76693. * Convert Specular Glossiness Textures to Metallic Roughness
  76694. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76695. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76696. * @param diffuseTexture texture used to store diffuse information
  76697. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76698. * @param factors specular glossiness material factors
  76699. * @param mimeType the mime type to use for the texture
  76700. * @returns pbr metallic roughness interface or null
  76701. */
  76702. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76703. /**
  76704. * Converts specular glossiness material properties to metallic roughness
  76705. * @param specularGlossiness interface with specular glossiness material properties
  76706. * @returns interface with metallic roughness material properties
  76707. */
  76708. private _convertSpecularGlossinessToMetallicRoughness;
  76709. /**
  76710. * Calculates the surface reflectance, independent of lighting conditions
  76711. * @param color Color source to calculate brightness from
  76712. * @returns number representing the perceived brightness, or zero if color is undefined
  76713. */
  76714. private _getPerceivedBrightness;
  76715. /**
  76716. * Returns the maximum color component value
  76717. * @param color
  76718. * @returns maximum color component value, or zero if color is null or undefined
  76719. */
  76720. private _getMaxComponent;
  76721. /**
  76722. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76723. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76724. * @param mimeType mime type to use for the textures
  76725. * @param images array of glTF image interfaces
  76726. * @param textures array of glTF texture interfaces
  76727. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76728. * @param imageData map of image file name to data
  76729. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76730. * @returns glTF PBR Metallic Roughness factors
  76731. */
  76732. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76733. private _getGLTFTextureSampler;
  76734. private _getGLTFTextureWrapMode;
  76735. private _getGLTFTextureWrapModesSampler;
  76736. /**
  76737. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76738. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76739. * @param mimeType mime type to use for the textures
  76740. * @param images array of glTF image interfaces
  76741. * @param textures array of glTF texture interfaces
  76742. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76743. * @param imageData map of image file name to data
  76744. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76745. * @returns glTF PBR Metallic Roughness factors
  76746. */
  76747. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76748. /**
  76749. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76750. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76751. * @param mimeType mime type to use for the textures
  76752. * @param images array of glTF image interfaces
  76753. * @param textures array of glTF texture interfaces
  76754. * @param materials array of glTF material interfaces
  76755. * @param imageData map of image file name to data
  76756. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76757. */
  76758. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76759. private setMetallicRoughnessPbrMaterial;
  76760. private getPixelsFromTexture;
  76761. /**
  76762. * Extracts a texture from a Babylon texture into file data and glTF data
  76763. * @param babylonTexture Babylon texture to extract
  76764. * @param mimeType Mime Type of the babylonTexture
  76765. * @return glTF texture info, or null if the texture format is not supported
  76766. */
  76767. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76768. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76769. /**
  76770. * Builds a texture from base64 string
  76771. * @param base64Texture base64 texture string
  76772. * @param baseTextureName Name to use for the texture
  76773. * @param mimeType image mime type for the texture
  76774. * @param images array of images
  76775. * @param textures array of textures
  76776. * @param imageData map of image data
  76777. * @returns glTF texture info, or null if the texture format is not supported
  76778. */
  76779. private _getTextureInfoFromBase64;
  76780. }
  76781. }
  76782. declare module BABYLON {
  76783. /**
  76784. * Class for holding and downloading glTF file data
  76785. */
  76786. export class GLTFData {
  76787. /**
  76788. * Object which contains the file name as the key and its data as the value
  76789. */
  76790. glTFFiles: {
  76791. [fileName: string]: string | Blob;
  76792. };
  76793. /**
  76794. * Initializes the glTF file object
  76795. */
  76796. constructor();
  76797. /**
  76798. * Downloads the glTF data as files based on their names and data
  76799. */
  76800. downloadFiles(): void;
  76801. }
  76802. }
  76803. declare module BABYLON {
  76804. /**
  76805. * Holds a collection of exporter options and parameters
  76806. */
  76807. export interface IExportOptions {
  76808. /**
  76809. * Function which indicates whether a babylon node should be exported or not
  76810. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76811. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76812. */
  76813. shouldExportNode?(node: Node): boolean;
  76814. /**
  76815. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76816. * @param metadata source metadata to read from
  76817. * @returns the data to store to glTF node extras
  76818. */
  76819. metadataSelector?(metadata: any): any;
  76820. /**
  76821. * The sample rate to bake animation curves
  76822. */
  76823. animationSampleRate?: number;
  76824. /**
  76825. * Begin serialization without waiting for the scene to be ready
  76826. */
  76827. exportWithoutWaitingForScene?: boolean;
  76828. /**
  76829. * Indicates if coordinate system swapping root nodes should be included in export
  76830. */
  76831. includeCoordinateSystemConversionNodes?: boolean;
  76832. }
  76833. /**
  76834. * Class for generating glTF data from a Babylon scene.
  76835. */
  76836. export class GLTF2Export {
  76837. /**
  76838. * Exports the geometry of the scene to .gltf file format asynchronously
  76839. * @param scene Babylon scene with scene hierarchy information
  76840. * @param filePrefix File prefix to use when generating the glTF file
  76841. * @param options Exporter options
  76842. * @returns Returns an object with a .gltf file and associates texture names
  76843. * as keys and their data and paths as values
  76844. */
  76845. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76846. private static _PreExportAsync;
  76847. private static _PostExportAsync;
  76848. /**
  76849. * Exports the geometry of the scene to .glb file format asychronously
  76850. * @param scene Babylon scene with scene hierarchy information
  76851. * @param filePrefix File prefix to use when generating glb file
  76852. * @param options Exporter options
  76853. * @returns Returns an object with a .glb filename as key and data as value
  76854. */
  76855. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76856. }
  76857. }
  76858. declare module BABYLON.GLTF2.Exporter {
  76859. /**
  76860. * @hidden
  76861. */
  76862. export class _GLTFUtilities {
  76863. /**
  76864. * Creates a buffer view based on the supplied arguments
  76865. * @param bufferIndex index value of the specified buffer
  76866. * @param byteOffset byte offset value
  76867. * @param byteLength byte length of the bufferView
  76868. * @param byteStride byte distance between conequential elements
  76869. * @param name name of the buffer view
  76870. * @returns bufferView for glTF
  76871. */
  76872. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76873. /**
  76874. * Creates an accessor based on the supplied arguments
  76875. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76876. * @param name The name of the accessor
  76877. * @param type The type of the accessor
  76878. * @param componentType The datatype of components in the attribute
  76879. * @param count The number of attributes referenced by this accessor
  76880. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76881. * @param min Minimum value of each component in this attribute
  76882. * @param max Maximum value of each component in this attribute
  76883. * @returns accessor for glTF
  76884. */
  76885. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76886. /**
  76887. * Calculates the minimum and maximum values of an array of position floats
  76888. * @param positions Positions array of a mesh
  76889. * @param vertexStart Starting vertex offset to calculate min and max values
  76890. * @param vertexCount Number of vertices to check for min and max values
  76891. * @returns min number array and max number array
  76892. */
  76893. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76894. min: number[];
  76895. max: number[];
  76896. };
  76897. /**
  76898. * Converts a new right-handed Vector3
  76899. * @param vector vector3 array
  76900. * @returns right-handed Vector3
  76901. */
  76902. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76903. /**
  76904. * Converts a Vector3 to right-handed
  76905. * @param vector Vector3 to convert to right-handed
  76906. */
  76907. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76908. /**
  76909. * Converts a three element number array to right-handed
  76910. * @param vector number array to convert to right-handed
  76911. */
  76912. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76913. /**
  76914. * Converts a new right-handed Vector3
  76915. * @param vector vector3 array
  76916. * @returns right-handed Vector3
  76917. */
  76918. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76919. /**
  76920. * Converts a Vector3 to right-handed
  76921. * @param vector Vector3 to convert to right-handed
  76922. */
  76923. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76924. /**
  76925. * Converts a three element number array to right-handed
  76926. * @param vector number array to convert to right-handed
  76927. */
  76928. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76929. /**
  76930. * Converts a Vector4 to right-handed
  76931. * @param vector Vector4 to convert to right-handed
  76932. */
  76933. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76934. /**
  76935. * Converts a Vector4 to right-handed
  76936. * @param vector Vector4 to convert to right-handed
  76937. */
  76938. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76939. /**
  76940. * Converts a Quaternion to right-handed
  76941. * @param quaternion Source quaternion to convert to right-handed
  76942. */
  76943. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76944. /**
  76945. * Converts a Quaternion to right-handed
  76946. * @param quaternion Source quaternion to convert to right-handed
  76947. */
  76948. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76949. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76950. }
  76951. }
  76952. declare module BABYLON.GLTF2.Exporter {
  76953. /**
  76954. * Converts Babylon Scene into glTF 2.0.
  76955. * @hidden
  76956. */
  76957. export class _Exporter {
  76958. /**
  76959. * Stores the glTF to export
  76960. */
  76961. _glTF: IGLTF;
  76962. /**
  76963. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76964. */
  76965. _bufferViews: IBufferView[];
  76966. /**
  76967. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76968. */
  76969. _accessors: IAccessor[];
  76970. /**
  76971. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76972. */
  76973. private _nodes;
  76974. /**
  76975. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76976. */
  76977. private _scenes;
  76978. /**
  76979. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76980. */
  76981. private _meshes;
  76982. /**
  76983. * Stores all the generated material information, which represents the appearance of each primitive
  76984. */
  76985. _materials: IMaterial[];
  76986. _materialMap: {
  76987. [materialID: number]: number;
  76988. };
  76989. /**
  76990. * Stores all the generated texture information, which is referenced by glTF materials
  76991. */
  76992. _textures: ITexture[];
  76993. /**
  76994. * Stores all the generated image information, which is referenced by glTF textures
  76995. */
  76996. _images: IImage[];
  76997. /**
  76998. * Stores all the texture samplers
  76999. */
  77000. _samplers: ISampler[];
  77001. /**
  77002. * Stores all the generated animation samplers, which is referenced by glTF animations
  77003. */
  77004. /**
  77005. * Stores the animations for glTF models
  77006. */
  77007. private _animations;
  77008. /**
  77009. * Stores the total amount of bytes stored in the glTF buffer
  77010. */
  77011. private _totalByteLength;
  77012. /**
  77013. * Stores a reference to the Babylon scene containing the source geometry and material information
  77014. */
  77015. _babylonScene: Scene;
  77016. /**
  77017. * Stores a map of the image data, where the key is the file name and the value
  77018. * is the image data
  77019. */
  77020. _imageData: {
  77021. [fileName: string]: {
  77022. data: Uint8Array;
  77023. mimeType: ImageMimeType;
  77024. };
  77025. };
  77026. /**
  77027. * Stores a map of the unique id of a node to its index in the node array
  77028. */
  77029. private _nodeMap;
  77030. /**
  77031. * Specifies if the source Babylon scene was left handed, and needed conversion.
  77032. */
  77033. _convertToRightHandedSystem: boolean;
  77034. /**
  77035. * Specifies if a Babylon node should be converted to right-handed on export
  77036. */
  77037. _convertToRightHandedSystemMap: {
  77038. [nodeId: number]: boolean;
  77039. };
  77040. _includeCoordinateSystemConversionNodes: boolean;
  77041. /**
  77042. * Baked animation sample rate
  77043. */
  77044. private _animationSampleRate;
  77045. private _options;
  77046. private _localEngine;
  77047. _glTFMaterialExporter: _GLTFMaterialExporter;
  77048. private _extensions;
  77049. private static _ExtensionNames;
  77050. private static _ExtensionFactories;
  77051. private _applyExtension;
  77052. private _applyExtensions;
  77053. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  77054. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  77055. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  77056. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  77057. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  77058. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  77059. private _forEachExtensions;
  77060. private _extensionsOnExporting;
  77061. /**
  77062. * Load glTF serializer extensions
  77063. */
  77064. private _loadExtensions;
  77065. /**
  77066. * Creates a glTF Exporter instance, which can accept optional exporter options
  77067. * @param babylonScene Babylon scene object
  77068. * @param options Options to modify the behavior of the exporter
  77069. */
  77070. constructor(babylonScene: Scene, options?: IExportOptions);
  77071. dispose(): void;
  77072. /**
  77073. * Registers a glTF exporter extension
  77074. * @param name Name of the extension to export
  77075. * @param factory The factory function that creates the exporter extension
  77076. */
  77077. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  77078. /**
  77079. * Un-registers an exporter extension
  77080. * @param name The name fo the exporter extension
  77081. * @returns A boolean indicating whether the extension has been un-registered
  77082. */
  77083. static UnregisterExtension(name: string): boolean;
  77084. /**
  77085. * Lazy load a local engine
  77086. */
  77087. _getLocalEngine(): Engine;
  77088. private reorderIndicesBasedOnPrimitiveMode;
  77089. /**
  77090. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  77091. * clock-wise during export to glTF
  77092. * @param submesh BabylonJS submesh
  77093. * @param primitiveMode Primitive mode of the mesh
  77094. * @param sideOrientation the winding order of the submesh
  77095. * @param vertexBufferKind The type of vertex attribute
  77096. * @param meshAttributeArray The vertex attribute data
  77097. * @param byteOffset The offset to the binary data
  77098. * @param binaryWriter The binary data for the glTF file
  77099. * @param convertToRightHandedSystem Converts the values to right-handed
  77100. */
  77101. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  77102. /**
  77103. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  77104. * clock-wise during export to glTF
  77105. * @param submesh BabylonJS submesh
  77106. * @param primitiveMode Primitive mode of the mesh
  77107. * @param sideOrientation the winding order of the submesh
  77108. * @param vertexBufferKind The type of vertex attribute
  77109. * @param meshAttributeArray The vertex attribute data
  77110. * @param byteOffset The offset to the binary data
  77111. * @param binaryWriter The binary data for the glTF file
  77112. * @param convertToRightHandedSystem Converts the values to right-handed
  77113. */
  77114. private reorderTriangleFillMode;
  77115. /**
  77116. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  77117. * clock-wise during export to glTF
  77118. * @param submesh BabylonJS submesh
  77119. * @param primitiveMode Primitive mode of the mesh
  77120. * @param sideOrientation the winding order of the submesh
  77121. * @param vertexBufferKind The type of vertex attribute
  77122. * @param meshAttributeArray The vertex attribute data
  77123. * @param byteOffset The offset to the binary data
  77124. * @param binaryWriter The binary data for the glTF file
  77125. * @param convertToRightHandedSystem Converts the values to right-handed
  77126. */
  77127. private reorderTriangleStripDrawMode;
  77128. /**
  77129. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77130. * clock-wise during export to glTF
  77131. * @param submesh BabylonJS submesh
  77132. * @param primitiveMode Primitive mode of the mesh
  77133. * @param sideOrientation the winding order of the submesh
  77134. * @param vertexBufferKind The type of vertex attribute
  77135. * @param meshAttributeArray The vertex attribute data
  77136. * @param byteOffset The offset to the binary data
  77137. * @param binaryWriter The binary data for the glTF file
  77138. * @param convertToRightHandedSystem Converts the values to right-handed
  77139. */
  77140. private reorderTriangleFanMode;
  77141. /**
  77142. * Writes the vertex attribute data to binary
  77143. * @param vertices The vertices to write to the binary writer
  77144. * @param byteOffset The offset into the binary writer to overwrite binary data
  77145. * @param vertexAttributeKind The vertex attribute type
  77146. * @param meshAttributeArray The vertex attribute data
  77147. * @param binaryWriter The writer containing the binary data
  77148. * @param convertToRightHandedSystem Converts the values to right-handed
  77149. */
  77150. private writeVertexAttributeData;
  77151. /**
  77152. * Writes mesh attribute data to a data buffer
  77153. * Returns the bytelength of the data
  77154. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77155. * @param meshAttributeArray Array containing the attribute data
  77156. * @param binaryWriter The buffer to write the binary data to
  77157. * @param indices Used to specify the order of the vertex data
  77158. * @param convertToRightHandedSystem Converts the values to right-handed
  77159. */
  77160. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean): void;
  77161. /**
  77162. * Generates glTF json data
  77163. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77164. * @param glTFPrefix Text to use when prefixing a glTF file
  77165. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77166. * @returns json data as string
  77167. */
  77168. private generateJSON;
  77169. /**
  77170. * Generates data for .gltf and .bin files based on the glTF prefix string
  77171. * @param glTFPrefix Text to use when prefixing a glTF file
  77172. * @param dispose Dispose the exporter
  77173. * @returns GLTFData with glTF file data
  77174. */
  77175. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77176. /**
  77177. * Creates a binary buffer for glTF
  77178. * @returns array buffer for binary data
  77179. */
  77180. private _generateBinaryAsync;
  77181. /**
  77182. * Pads the number to a multiple of 4
  77183. * @param num number to pad
  77184. * @returns padded number
  77185. */
  77186. private _getPadding;
  77187. /**
  77188. * @hidden
  77189. */
  77190. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77191. /**
  77192. * Sets the TRS for each node
  77193. * @param node glTF Node for storing the transformation data
  77194. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77195. * @param convertToRightHandedSystem Converts the values to right-handed
  77196. */
  77197. private setNodeTransformation;
  77198. private getVertexBufferFromMesh;
  77199. /**
  77200. * Creates a bufferview based on the vertices type for the Babylon mesh
  77201. * @param kind Indicates the type of vertices data
  77202. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77203. * @param binaryWriter The buffer to write the bufferview data to
  77204. * @param convertToRightHandedSystem Converts the values to right-handed
  77205. */
  77206. private createBufferViewKind;
  77207. /**
  77208. * The primitive mode of the Babylon mesh
  77209. * @param babylonMesh The BabylonJS mesh
  77210. */
  77211. private getMeshPrimitiveMode;
  77212. /**
  77213. * Sets the primitive mode of the glTF mesh primitive
  77214. * @param meshPrimitive glTF mesh primitive
  77215. * @param primitiveMode The primitive mode
  77216. */
  77217. private setPrimitiveMode;
  77218. /**
  77219. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77220. * @param meshPrimitive glTF mesh primitive
  77221. * @param attributeKind vertex attribute
  77222. * @returns boolean specifying if uv coordinates are present
  77223. */
  77224. private setAttributeKind;
  77225. /**
  77226. * Sets data for the primitive attributes of each submesh
  77227. * @param mesh glTF Mesh object to store the primitive attribute information
  77228. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77229. * @param binaryWriter Buffer to write the attribute data to
  77230. * @param convertToRightHandedSystem Converts the values to right-handed
  77231. */
  77232. private setPrimitiveAttributesAsync;
  77233. /**
  77234. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  77235. * @param node The node to check
  77236. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  77237. */
  77238. private isBabylonCoordinateSystemConvertingNode;
  77239. /**
  77240. * Creates a glTF scene based on the array of meshes
  77241. * Returns the the total byte offset
  77242. * @param babylonScene Babylon scene to get the mesh data from
  77243. * @param binaryWriter Buffer to write binary data to
  77244. */
  77245. private createSceneAsync;
  77246. /**
  77247. * Creates a mapping of Node unique id to node index and handles animations
  77248. * @param babylonScene Babylon Scene
  77249. * @param nodes Babylon transform nodes
  77250. * @param binaryWriter Buffer to write binary data to
  77251. * @returns Node mapping of unique id to index
  77252. */
  77253. private createNodeMapAndAnimationsAsync;
  77254. /**
  77255. * Creates a glTF node from a Babylon mesh
  77256. * @param babylonMesh Source Babylon mesh
  77257. * @param binaryWriter Buffer for storing geometry data
  77258. * @param convertToRightHandedSystem Converts the values to right-handed
  77259. * @returns glTF node
  77260. */
  77261. private createNodeAsync;
  77262. }
  77263. /**
  77264. * @hidden
  77265. *
  77266. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77267. */
  77268. export class _BinaryWriter {
  77269. /**
  77270. * Array buffer which stores all binary data
  77271. */
  77272. private _arrayBuffer;
  77273. /**
  77274. * View of the array buffer
  77275. */
  77276. private _dataView;
  77277. /**
  77278. * byte offset of data in array buffer
  77279. */
  77280. private _byteOffset;
  77281. /**
  77282. * Initialize binary writer with an initial byte length
  77283. * @param byteLength Initial byte length of the array buffer
  77284. */
  77285. constructor(byteLength: number);
  77286. /**
  77287. * Resize the array buffer to the specified byte length
  77288. * @param byteLength
  77289. */
  77290. private resizeBuffer;
  77291. /**
  77292. * Get an array buffer with the length of the byte offset
  77293. * @returns ArrayBuffer resized to the byte offset
  77294. */
  77295. getArrayBuffer(): ArrayBuffer;
  77296. /**
  77297. * Get the byte offset of the array buffer
  77298. * @returns byte offset
  77299. */
  77300. getByteOffset(): number;
  77301. /**
  77302. * Stores an UInt8 in the array buffer
  77303. * @param entry
  77304. * @param byteOffset If defined, specifies where to set the value as an offset.
  77305. */
  77306. setUInt8(entry: number, byteOffset?: number): void;
  77307. /**
  77308. * Gets an UInt32 in the array buffer
  77309. * @param entry
  77310. * @param byteOffset If defined, specifies where to set the value as an offset.
  77311. */
  77312. getUInt32(byteOffset: number): number;
  77313. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77314. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77315. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77316. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77317. /**
  77318. * Stores a Float32 in the array buffer
  77319. * @param entry
  77320. */
  77321. setFloat32(entry: number, byteOffset?: number): void;
  77322. /**
  77323. * Stores an UInt32 in the array buffer
  77324. * @param entry
  77325. * @param byteOffset If defined, specifies where to set the value as an offset.
  77326. */
  77327. setUInt32(entry: number, byteOffset?: number): void;
  77328. }
  77329. }
  77330. declare module BABYLON.GLTF2.Exporter {
  77331. /**
  77332. * @hidden
  77333. * Interface to store animation data.
  77334. */
  77335. export interface _IAnimationData {
  77336. /**
  77337. * Keyframe data.
  77338. */
  77339. inputs: number[];
  77340. /**
  77341. * Value data.
  77342. */
  77343. outputs: number[][];
  77344. /**
  77345. * Animation interpolation data.
  77346. */
  77347. samplerInterpolation: AnimationSamplerInterpolation;
  77348. /**
  77349. * Minimum keyframe value.
  77350. */
  77351. inputsMin: number;
  77352. /**
  77353. * Maximum keyframe value.
  77354. */
  77355. inputsMax: number;
  77356. }
  77357. /**
  77358. * @hidden
  77359. */
  77360. export interface _IAnimationInfo {
  77361. /**
  77362. * The target channel for the animation
  77363. */
  77364. animationChannelTargetPath: AnimationChannelTargetPath;
  77365. /**
  77366. * The glTF accessor type for the data.
  77367. */
  77368. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77369. /**
  77370. * Specifies if quaternions should be used.
  77371. */
  77372. useQuaternion: boolean;
  77373. }
  77374. /**
  77375. * @hidden
  77376. * Utility class for generating glTF animation data from BabylonJS.
  77377. */
  77378. export class _GLTFAnimation {
  77379. /**
  77380. * @ignore
  77381. *
  77382. * Creates glTF channel animation from BabylonJS animation.
  77383. * @param babylonTransformNode - BabylonJS mesh.
  77384. * @param animation - animation.
  77385. * @param animationChannelTargetPath - The target animation channel.
  77386. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77387. * @param useQuaternion - Specifies if quaternions are used.
  77388. * @returns nullable IAnimationData
  77389. */
  77390. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77391. private static _DeduceAnimationInfo;
  77392. /**
  77393. * @ignore
  77394. * Create node animations from the transform node animations
  77395. * @param babylonNode
  77396. * @param runtimeGLTFAnimation
  77397. * @param idleGLTFAnimations
  77398. * @param nodeMap
  77399. * @param nodes
  77400. * @param binaryWriter
  77401. * @param bufferViews
  77402. * @param accessors
  77403. * @param convertToRightHandedSystem
  77404. * @param animationSampleRate
  77405. */
  77406. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77407. [key: number]: number;
  77408. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77409. /**
  77410. * @ignore
  77411. * Create node animations from the animation groups
  77412. * @param babylonScene
  77413. * @param glTFAnimations
  77414. * @param nodeMap
  77415. * @param nodes
  77416. * @param binaryWriter
  77417. * @param bufferViews
  77418. * @param accessors
  77419. * @param convertToRightHandedSystemMap
  77420. * @param animationSampleRate
  77421. */
  77422. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77423. [key: number]: number;
  77424. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  77425. [nodeId: number]: boolean;
  77426. }, animationSampleRate: number): void;
  77427. private static AddAnimation;
  77428. /**
  77429. * Create a baked animation
  77430. * @param babylonTransformNode BabylonJS mesh
  77431. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77432. * @param animationChannelTargetPath animation target channel
  77433. * @param minFrame minimum animation frame
  77434. * @param maxFrame maximum animation frame
  77435. * @param fps frames per second of the animation
  77436. * @param inputs input key frames of the animation
  77437. * @param outputs output key frame data of the animation
  77438. * @param convertToRightHandedSystem converts the values to right-handed
  77439. * @param useQuaternion specifies if quaternions should be used
  77440. */
  77441. private static _CreateBakedAnimation;
  77442. private static _ConvertFactorToVector3OrQuaternion;
  77443. private static _SetInterpolatedValue;
  77444. /**
  77445. * Creates linear animation from the animation key frames
  77446. * @param babylonTransformNode BabylonJS mesh
  77447. * @param animation BabylonJS animation
  77448. * @param animationChannelTargetPath The target animation channel
  77449. * @param frameDelta The difference between the last and first frame of the animation
  77450. * @param inputs Array to store the key frame times
  77451. * @param outputs Array to store the key frame data
  77452. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77453. * @param useQuaternion Specifies if quaternions are used in the animation
  77454. */
  77455. private static _CreateLinearOrStepAnimation;
  77456. /**
  77457. * Creates cubic spline animation from the animation key frames
  77458. * @param babylonTransformNode BabylonJS mesh
  77459. * @param animation BabylonJS animation
  77460. * @param animationChannelTargetPath The target animation channel
  77461. * @param frameDelta The difference between the last and first frame of the animation
  77462. * @param inputs Array to store the key frame times
  77463. * @param outputs Array to store the key frame data
  77464. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77465. * @param useQuaternion Specifies if quaternions are used in the animation
  77466. */
  77467. private static _CreateCubicSplineAnimation;
  77468. private static _GetBasePositionRotationOrScale;
  77469. /**
  77470. * Adds a key frame value
  77471. * @param keyFrame
  77472. * @param animation
  77473. * @param outputs
  77474. * @param animationChannelTargetPath
  77475. * @param basePositionRotationOrScale
  77476. * @param convertToRightHandedSystem
  77477. * @param useQuaternion
  77478. */
  77479. private static _AddKeyframeValue;
  77480. /**
  77481. * Determine the interpolation based on the key frames
  77482. * @param keyFrames
  77483. * @param animationChannelTargetPath
  77484. * @param useQuaternion
  77485. */
  77486. private static _DeduceInterpolation;
  77487. /**
  77488. * Adds an input tangent or output tangent to the output data
  77489. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77490. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77491. * @param outputs The animation data by keyframe
  77492. * @param animationChannelTargetPath The target animation channel
  77493. * @param interpolation The interpolation type
  77494. * @param keyFrame The key frame with the animation data
  77495. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77496. * @param useQuaternion Specifies if quaternions are used
  77497. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77498. */
  77499. private static AddSplineTangent;
  77500. /**
  77501. * Get the minimum and maximum key frames' frame values
  77502. * @param keyFrames animation key frames
  77503. * @returns the minimum and maximum key frame value
  77504. */
  77505. private static calculateMinMaxKeyFrames;
  77506. }
  77507. }
  77508. declare module BABYLON.GLTF2.Exporter {
  77509. /** @hidden */
  77510. export var textureTransformPixelShader: {
  77511. name: string;
  77512. shader: string;
  77513. };
  77514. }
  77515. declare module BABYLON.GLTF2.Exporter.Extensions {
  77516. /**
  77517. * @hidden
  77518. */
  77519. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77520. private _recordedTextures;
  77521. /** Name of this extension */
  77522. readonly name: string;
  77523. /** Defines whether this extension is enabled */
  77524. enabled: boolean;
  77525. /** Defines whether this extension is required */
  77526. required: boolean;
  77527. /** Reference to the glTF exporter */
  77528. private _wasUsed;
  77529. constructor(exporter: _Exporter);
  77530. dispose(): void;
  77531. /** @hidden */
  77532. get wasUsed(): boolean;
  77533. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77534. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77535. /**
  77536. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77537. * @param babylonTexture
  77538. * @param offset
  77539. * @param rotation
  77540. * @param scale
  77541. * @param scene
  77542. */
  77543. private _textureTransformTextureAsync;
  77544. }
  77545. }
  77546. declare module BABYLON.GLTF2.Exporter.Extensions {
  77547. /**
  77548. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77549. */
  77550. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77551. /** The name of this extension. */
  77552. readonly name: string;
  77553. /** Defines whether this extension is enabled. */
  77554. enabled: boolean;
  77555. /** Defines whether this extension is required */
  77556. required: boolean;
  77557. /** Reference to the glTF exporter */
  77558. private _exporter;
  77559. private _lights;
  77560. /** @hidden */
  77561. constructor(exporter: _Exporter);
  77562. /** @hidden */
  77563. dispose(): void;
  77564. /** @hidden */
  77565. get wasUsed(): boolean;
  77566. /** @hidden */
  77567. onExporting(): void;
  77568. /**
  77569. * Define this method to modify the default behavior when exporting a node
  77570. * @param context The context when exporting the node
  77571. * @param node glTF node
  77572. * @param babylonNode BabylonJS node
  77573. * @returns nullable INode promise
  77574. */
  77575. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  77576. }
  77577. }
  77578. declare module BABYLON.GLTF2.Exporter.Extensions {
  77579. /**
  77580. * @hidden
  77581. */
  77582. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77583. /** Name of this extension */
  77584. readonly name: string;
  77585. /** Defines whether this extension is enabled */
  77586. enabled: boolean;
  77587. /** Defines whether this extension is required */
  77588. required: boolean;
  77589. /** Reference to the glTF exporter */
  77590. private _textureInfos;
  77591. private _exportedTextures;
  77592. private _wasUsed;
  77593. constructor(exporter: _Exporter);
  77594. dispose(): void;
  77595. /** @hidden */
  77596. get wasUsed(): boolean;
  77597. private _getTextureIndex;
  77598. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77599. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77600. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77601. }
  77602. }
  77603. declare module BABYLON {
  77604. /**
  77605. * Class for generating STL data from a Babylon scene.
  77606. */
  77607. export class STLExport {
  77608. /**
  77609. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77610. * @param meshes list defines the mesh to serialize
  77611. * @param download triggers the automatic download of the file.
  77612. * @param fileName changes the downloads fileName.
  77613. * @param binary changes the STL to a binary type.
  77614. * @param isLittleEndian toggle for binary type exporter.
  77615. * @returns the STL as UTF8 string
  77616. */
  77617. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77618. }
  77619. }
  77620. declare module "babylonjs-gltf2interface" {
  77621. export = BABYLON.GLTF2;
  77622. }
  77623. /**
  77624. * Module for glTF 2.0 Interface
  77625. */
  77626. declare module BABYLON.GLTF2 {
  77627. /**
  77628. * The datatype of the components in the attribute
  77629. */
  77630. const enum AccessorComponentType {
  77631. /**
  77632. * Byte
  77633. */
  77634. BYTE = 5120,
  77635. /**
  77636. * Unsigned Byte
  77637. */
  77638. UNSIGNED_BYTE = 5121,
  77639. /**
  77640. * Short
  77641. */
  77642. SHORT = 5122,
  77643. /**
  77644. * Unsigned Short
  77645. */
  77646. UNSIGNED_SHORT = 5123,
  77647. /**
  77648. * Unsigned Int
  77649. */
  77650. UNSIGNED_INT = 5125,
  77651. /**
  77652. * Float
  77653. */
  77654. FLOAT = 5126,
  77655. }
  77656. /**
  77657. * Specifies if the attirbute is a scalar, vector, or matrix
  77658. */
  77659. const enum AccessorType {
  77660. /**
  77661. * Scalar
  77662. */
  77663. SCALAR = "SCALAR",
  77664. /**
  77665. * Vector2
  77666. */
  77667. VEC2 = "VEC2",
  77668. /**
  77669. * Vector3
  77670. */
  77671. VEC3 = "VEC3",
  77672. /**
  77673. * Vector4
  77674. */
  77675. VEC4 = "VEC4",
  77676. /**
  77677. * Matrix2x2
  77678. */
  77679. MAT2 = "MAT2",
  77680. /**
  77681. * Matrix3x3
  77682. */
  77683. MAT3 = "MAT3",
  77684. /**
  77685. * Matrix4x4
  77686. */
  77687. MAT4 = "MAT4",
  77688. }
  77689. /**
  77690. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77691. */
  77692. const enum AnimationChannelTargetPath {
  77693. /**
  77694. * Translation
  77695. */
  77696. TRANSLATION = "translation",
  77697. /**
  77698. * Rotation
  77699. */
  77700. ROTATION = "rotation",
  77701. /**
  77702. * Scale
  77703. */
  77704. SCALE = "scale",
  77705. /**
  77706. * Weights
  77707. */
  77708. WEIGHTS = "weights",
  77709. }
  77710. /**
  77711. * Interpolation algorithm
  77712. */
  77713. const enum AnimationSamplerInterpolation {
  77714. /**
  77715. * The animated values are linearly interpolated between keyframes
  77716. */
  77717. LINEAR = "LINEAR",
  77718. /**
  77719. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77720. */
  77721. STEP = "STEP",
  77722. /**
  77723. * The animation's interpolation is computed using a cubic spline with specified tangents
  77724. */
  77725. CUBICSPLINE = "CUBICSPLINE",
  77726. }
  77727. /**
  77728. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77729. */
  77730. const enum CameraType {
  77731. /**
  77732. * A perspective camera containing properties to create a perspective projection matrix
  77733. */
  77734. PERSPECTIVE = "perspective",
  77735. /**
  77736. * An orthographic camera containing properties to create an orthographic projection matrix
  77737. */
  77738. ORTHOGRAPHIC = "orthographic",
  77739. }
  77740. /**
  77741. * The mime-type of the image
  77742. */
  77743. const enum ImageMimeType {
  77744. /**
  77745. * JPEG Mime-type
  77746. */
  77747. JPEG = "image/jpeg",
  77748. /**
  77749. * PNG Mime-type
  77750. */
  77751. PNG = "image/png",
  77752. }
  77753. /**
  77754. * The alpha rendering mode of the material
  77755. */
  77756. const enum MaterialAlphaMode {
  77757. /**
  77758. * The alpha value is ignored and the rendered output is fully opaque
  77759. */
  77760. OPAQUE = "OPAQUE",
  77761. /**
  77762. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77763. */
  77764. MASK = "MASK",
  77765. /**
  77766. * 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)
  77767. */
  77768. BLEND = "BLEND",
  77769. }
  77770. /**
  77771. * The type of the primitives to render
  77772. */
  77773. const enum MeshPrimitiveMode {
  77774. /**
  77775. * Points
  77776. */
  77777. POINTS = 0,
  77778. /**
  77779. * Lines
  77780. */
  77781. LINES = 1,
  77782. /**
  77783. * Line Loop
  77784. */
  77785. LINE_LOOP = 2,
  77786. /**
  77787. * Line Strip
  77788. */
  77789. LINE_STRIP = 3,
  77790. /**
  77791. * Triangles
  77792. */
  77793. TRIANGLES = 4,
  77794. /**
  77795. * Triangle Strip
  77796. */
  77797. TRIANGLE_STRIP = 5,
  77798. /**
  77799. * Triangle Fan
  77800. */
  77801. TRIANGLE_FAN = 6,
  77802. }
  77803. /**
  77804. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77805. */
  77806. const enum TextureMagFilter {
  77807. /**
  77808. * Nearest
  77809. */
  77810. NEAREST = 9728,
  77811. /**
  77812. * Linear
  77813. */
  77814. LINEAR = 9729,
  77815. }
  77816. /**
  77817. * Minification filter. All valid values correspond to WebGL enums
  77818. */
  77819. const enum TextureMinFilter {
  77820. /**
  77821. * Nearest
  77822. */
  77823. NEAREST = 9728,
  77824. /**
  77825. * Linear
  77826. */
  77827. LINEAR = 9729,
  77828. /**
  77829. * Nearest Mip-Map Nearest
  77830. */
  77831. NEAREST_MIPMAP_NEAREST = 9984,
  77832. /**
  77833. * Linear Mipmap Nearest
  77834. */
  77835. LINEAR_MIPMAP_NEAREST = 9985,
  77836. /**
  77837. * Nearest Mipmap Linear
  77838. */
  77839. NEAREST_MIPMAP_LINEAR = 9986,
  77840. /**
  77841. * Linear Mipmap Linear
  77842. */
  77843. LINEAR_MIPMAP_LINEAR = 9987,
  77844. }
  77845. /**
  77846. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77847. */
  77848. const enum TextureWrapMode {
  77849. /**
  77850. * Clamp to Edge
  77851. */
  77852. CLAMP_TO_EDGE = 33071,
  77853. /**
  77854. * Mirrored Repeat
  77855. */
  77856. MIRRORED_REPEAT = 33648,
  77857. /**
  77858. * Repeat
  77859. */
  77860. REPEAT = 10497,
  77861. }
  77862. /**
  77863. * glTF Property
  77864. */
  77865. interface IProperty {
  77866. /**
  77867. * Dictionary object with extension-specific objects
  77868. */
  77869. extensions?: {
  77870. [key: string]: any;
  77871. };
  77872. /**
  77873. * Application-Specific data
  77874. */
  77875. extras?: any;
  77876. }
  77877. /**
  77878. * glTF Child of Root Property
  77879. */
  77880. interface IChildRootProperty extends IProperty {
  77881. /**
  77882. * The user-defined name of this object
  77883. */
  77884. name?: string;
  77885. }
  77886. /**
  77887. * Indices of those attributes that deviate from their initialization value
  77888. */
  77889. interface IAccessorSparseIndices extends IProperty {
  77890. /**
  77891. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77892. */
  77893. bufferView: number;
  77894. /**
  77895. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77896. */
  77897. byteOffset?: number;
  77898. /**
  77899. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77900. */
  77901. componentType: AccessorComponentType;
  77902. }
  77903. /**
  77904. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77905. */
  77906. interface IAccessorSparseValues extends IProperty {
  77907. /**
  77908. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77909. */
  77910. bufferView: number;
  77911. /**
  77912. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77913. */
  77914. byteOffset?: number;
  77915. }
  77916. /**
  77917. * Sparse storage of attributes that deviate from their initialization value
  77918. */
  77919. interface IAccessorSparse extends IProperty {
  77920. /**
  77921. * The number of attributes encoded in this sparse accessor
  77922. */
  77923. count: number;
  77924. /**
  77925. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77926. */
  77927. indices: IAccessorSparseIndices;
  77928. /**
  77929. * 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
  77930. */
  77931. values: IAccessorSparseValues;
  77932. }
  77933. /**
  77934. * 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
  77935. */
  77936. interface IAccessor extends IChildRootProperty {
  77937. /**
  77938. * The index of the bufferview
  77939. */
  77940. bufferView?: number;
  77941. /**
  77942. * The offset relative to the start of the bufferView in bytes
  77943. */
  77944. byteOffset?: number;
  77945. /**
  77946. * The datatype of components in the attribute
  77947. */
  77948. componentType: AccessorComponentType;
  77949. /**
  77950. * Specifies whether integer data values should be normalized
  77951. */
  77952. normalized?: boolean;
  77953. /**
  77954. * The number of attributes referenced by this accessor
  77955. */
  77956. count: number;
  77957. /**
  77958. * Specifies if the attribute is a scalar, vector, or matrix
  77959. */
  77960. type: AccessorType;
  77961. /**
  77962. * Maximum value of each component in this attribute
  77963. */
  77964. max?: number[];
  77965. /**
  77966. * Minimum value of each component in this attribute
  77967. */
  77968. min?: number[];
  77969. /**
  77970. * Sparse storage of attributes that deviate from their initialization value
  77971. */
  77972. sparse?: IAccessorSparse;
  77973. }
  77974. /**
  77975. * Targets an animation's sampler at a node's property
  77976. */
  77977. interface IAnimationChannel extends IProperty {
  77978. /**
  77979. * The index of a sampler in this animation used to compute the value for the target
  77980. */
  77981. sampler: number;
  77982. /**
  77983. * The index of the node and TRS property to target
  77984. */
  77985. target: IAnimationChannelTarget;
  77986. }
  77987. /**
  77988. * The index of the node and TRS property that an animation channel targets
  77989. */
  77990. interface IAnimationChannelTarget extends IProperty {
  77991. /**
  77992. * The index of the node to target
  77993. */
  77994. node: number;
  77995. /**
  77996. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77997. */
  77998. path: AnimationChannelTargetPath;
  77999. }
  78000. /**
  78001. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78002. */
  78003. interface IAnimationSampler extends IProperty {
  78004. /**
  78005. * The index of an accessor containing keyframe input values, e.g., time
  78006. */
  78007. input: number;
  78008. /**
  78009. * Interpolation algorithm
  78010. */
  78011. interpolation?: AnimationSamplerInterpolation;
  78012. /**
  78013. * The index of an accessor, containing keyframe output values
  78014. */
  78015. output: number;
  78016. }
  78017. /**
  78018. * A keyframe animation
  78019. */
  78020. interface IAnimation extends IChildRootProperty {
  78021. /**
  78022. * An array of channels, each of which targets an animation's sampler at a node's property
  78023. */
  78024. channels: IAnimationChannel[];
  78025. /**
  78026. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  78027. */
  78028. samplers: IAnimationSampler[];
  78029. }
  78030. /**
  78031. * Metadata about the glTF asset
  78032. */
  78033. interface IAsset extends IChildRootProperty {
  78034. /**
  78035. * A copyright message suitable for display to credit the content creator
  78036. */
  78037. copyright?: string;
  78038. /**
  78039. * Tool that generated this glTF model. Useful for debugging
  78040. */
  78041. generator?: string;
  78042. /**
  78043. * The glTF version that this asset targets
  78044. */
  78045. version: string;
  78046. /**
  78047. * The minimum glTF version that this asset targets
  78048. */
  78049. minVersion?: string;
  78050. }
  78051. /**
  78052. * A buffer points to binary geometry, animation, or skins
  78053. */
  78054. interface IBuffer extends IChildRootProperty {
  78055. /**
  78056. * 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
  78057. */
  78058. uri?: string;
  78059. /**
  78060. * The length of the buffer in bytes
  78061. */
  78062. byteLength: number;
  78063. }
  78064. /**
  78065. * A view into a buffer generally representing a subset of the buffer
  78066. */
  78067. interface IBufferView extends IChildRootProperty {
  78068. /**
  78069. * The index of the buffer
  78070. */
  78071. buffer: number;
  78072. /**
  78073. * The offset into the buffer in bytes
  78074. */
  78075. byteOffset?: number;
  78076. /**
  78077. * The lenth of the bufferView in bytes
  78078. */
  78079. byteLength: number;
  78080. /**
  78081. * The stride, in bytes
  78082. */
  78083. byteStride?: number;
  78084. }
  78085. /**
  78086. * An orthographic camera containing properties to create an orthographic projection matrix
  78087. */
  78088. interface ICameraOrthographic extends IProperty {
  78089. /**
  78090. * The floating-point horizontal magnification of the view. Must not be zero
  78091. */
  78092. xmag: number;
  78093. /**
  78094. * The floating-point vertical magnification of the view. Must not be zero
  78095. */
  78096. ymag: number;
  78097. /**
  78098. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  78099. */
  78100. zfar: number;
  78101. /**
  78102. * The floating-point distance to the near clipping plane
  78103. */
  78104. znear: number;
  78105. }
  78106. /**
  78107. * A perspective camera containing properties to create a perspective projection matrix
  78108. */
  78109. interface ICameraPerspective extends IProperty {
  78110. /**
  78111. * The floating-point aspect ratio of the field of view
  78112. */
  78113. aspectRatio?: number;
  78114. /**
  78115. * The floating-point vertical field of view in radians
  78116. */
  78117. yfov: number;
  78118. /**
  78119. * The floating-point distance to the far clipping plane
  78120. */
  78121. zfar?: number;
  78122. /**
  78123. * The floating-point distance to the near clipping plane
  78124. */
  78125. znear: number;
  78126. }
  78127. /**
  78128. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  78129. */
  78130. interface ICamera extends IChildRootProperty {
  78131. /**
  78132. * An orthographic camera containing properties to create an orthographic projection matrix
  78133. */
  78134. orthographic?: ICameraOrthographic;
  78135. /**
  78136. * A perspective camera containing properties to create a perspective projection matrix
  78137. */
  78138. perspective?: ICameraPerspective;
  78139. /**
  78140. * Specifies if the camera uses a perspective or orthographic projection
  78141. */
  78142. type: CameraType;
  78143. }
  78144. /**
  78145. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78146. */
  78147. interface IImage extends IChildRootProperty {
  78148. /**
  78149. * 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
  78150. */
  78151. uri?: string;
  78152. /**
  78153. * The image's MIME type
  78154. */
  78155. mimeType?: ImageMimeType;
  78156. /**
  78157. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78158. */
  78159. bufferView?: number;
  78160. }
  78161. /**
  78162. * Material Normal Texture Info
  78163. */
  78164. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78165. /**
  78166. * The scalar multiplier applied to each normal vector of the normal texture
  78167. */
  78168. scale?: number;
  78169. }
  78170. /**
  78171. * Material Occlusion Texture Info
  78172. */
  78173. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78174. /**
  78175. * A scalar multiplier controlling the amount of occlusion applied
  78176. */
  78177. strength?: number;
  78178. }
  78179. /**
  78180. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78181. */
  78182. interface IMaterialPbrMetallicRoughness {
  78183. /**
  78184. * The material's base color factor
  78185. */
  78186. baseColorFactor?: number[];
  78187. /**
  78188. * The base color texture
  78189. */
  78190. baseColorTexture?: ITextureInfo;
  78191. /**
  78192. * The metalness of the material
  78193. */
  78194. metallicFactor?: number;
  78195. /**
  78196. * The roughness of the material
  78197. */
  78198. roughnessFactor?: number;
  78199. /**
  78200. * The metallic-roughness texture
  78201. */
  78202. metallicRoughnessTexture?: ITextureInfo;
  78203. }
  78204. /**
  78205. * The material appearance of a primitive
  78206. */
  78207. interface IMaterial extends IChildRootProperty {
  78208. /**
  78209. * 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
  78210. */
  78211. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78212. /**
  78213. * The normal map texture
  78214. */
  78215. normalTexture?: IMaterialNormalTextureInfo;
  78216. /**
  78217. * The occlusion map texture
  78218. */
  78219. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78220. /**
  78221. * The emissive map texture
  78222. */
  78223. emissiveTexture?: ITextureInfo;
  78224. /**
  78225. * 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
  78226. */
  78227. emissiveFactor?: number[];
  78228. /**
  78229. * The alpha rendering mode of the material
  78230. */
  78231. alphaMode?: MaterialAlphaMode;
  78232. /**
  78233. * The alpha cutoff value of the material
  78234. */
  78235. alphaCutoff?: number;
  78236. /**
  78237. * Specifies whether the material is double sided
  78238. */
  78239. doubleSided?: boolean;
  78240. }
  78241. /**
  78242. * Geometry to be rendered with the given material
  78243. */
  78244. interface IMeshPrimitive extends IProperty {
  78245. /**
  78246. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78247. */
  78248. attributes: {
  78249. [name: string]: number;
  78250. };
  78251. /**
  78252. * The index of the accessor that contains the indices
  78253. */
  78254. indices?: number;
  78255. /**
  78256. * The index of the material to apply to this primitive when rendering
  78257. */
  78258. material?: number;
  78259. /**
  78260. * The type of primitives to render. All valid values correspond to WebGL enums
  78261. */
  78262. mode?: MeshPrimitiveMode;
  78263. /**
  78264. * 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
  78265. */
  78266. targets?: {
  78267. [name: string]: number;
  78268. }[];
  78269. }
  78270. /**
  78271. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78272. */
  78273. interface IMesh extends IChildRootProperty {
  78274. /**
  78275. * An array of primitives, each defining geometry to be rendered with a material
  78276. */
  78277. primitives: IMeshPrimitive[];
  78278. /**
  78279. * Array of weights to be applied to the Morph Targets
  78280. */
  78281. weights?: number[];
  78282. }
  78283. /**
  78284. * A node in the node hierarchy
  78285. */
  78286. interface INode extends IChildRootProperty {
  78287. /**
  78288. * The index of the camera referenced by this node
  78289. */
  78290. camera?: number;
  78291. /**
  78292. * The indices of this node's children
  78293. */
  78294. children?: number[];
  78295. /**
  78296. * The index of the skin referenced by this node
  78297. */
  78298. skin?: number;
  78299. /**
  78300. * A floating-point 4x4 transformation matrix stored in column-major order
  78301. */
  78302. matrix?: number[];
  78303. /**
  78304. * The index of the mesh in this node
  78305. */
  78306. mesh?: number;
  78307. /**
  78308. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78309. */
  78310. rotation?: number[];
  78311. /**
  78312. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78313. */
  78314. scale?: number[];
  78315. /**
  78316. * The node's translation along the x, y, and z axes
  78317. */
  78318. translation?: number[];
  78319. /**
  78320. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78321. */
  78322. weights?: number[];
  78323. }
  78324. /**
  78325. * Texture sampler properties for filtering and wrapping modes
  78326. */
  78327. interface ISampler extends IChildRootProperty {
  78328. /**
  78329. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78330. */
  78331. magFilter?: TextureMagFilter;
  78332. /**
  78333. * Minification filter. All valid values correspond to WebGL enums
  78334. */
  78335. minFilter?: TextureMinFilter;
  78336. /**
  78337. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78338. */
  78339. wrapS?: TextureWrapMode;
  78340. /**
  78341. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78342. */
  78343. wrapT?: TextureWrapMode;
  78344. }
  78345. /**
  78346. * The root nodes of a scene
  78347. */
  78348. interface IScene extends IChildRootProperty {
  78349. /**
  78350. * The indices of each root node
  78351. */
  78352. nodes: number[];
  78353. }
  78354. /**
  78355. * Joints and matrices defining a skin
  78356. */
  78357. interface ISkin extends IChildRootProperty {
  78358. /**
  78359. * 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
  78360. */
  78361. inverseBindMatrices?: number;
  78362. /**
  78363. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78364. */
  78365. skeleton?: number;
  78366. /**
  78367. * 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)
  78368. */
  78369. joints: number[];
  78370. }
  78371. /**
  78372. * A texture and its sampler
  78373. */
  78374. interface ITexture extends IChildRootProperty {
  78375. /**
  78376. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78377. */
  78378. sampler?: number;
  78379. /**
  78380. * The index of the image used by this texture
  78381. */
  78382. source: number;
  78383. }
  78384. /**
  78385. * Reference to a texture
  78386. */
  78387. interface ITextureInfo extends IProperty {
  78388. /**
  78389. * The index of the texture
  78390. */
  78391. index: number;
  78392. /**
  78393. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78394. */
  78395. texCoord?: number;
  78396. }
  78397. /**
  78398. * The root object for a glTF asset
  78399. */
  78400. interface IGLTF extends IProperty {
  78401. /**
  78402. * An array of accessors. An accessor is a typed view into a bufferView
  78403. */
  78404. accessors?: IAccessor[];
  78405. /**
  78406. * An array of keyframe animations
  78407. */
  78408. animations?: IAnimation[];
  78409. /**
  78410. * Metadata about the glTF asset
  78411. */
  78412. asset: IAsset;
  78413. /**
  78414. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78415. */
  78416. buffers?: IBuffer[];
  78417. /**
  78418. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78419. */
  78420. bufferViews?: IBufferView[];
  78421. /**
  78422. * An array of cameras
  78423. */
  78424. cameras?: ICamera[];
  78425. /**
  78426. * Names of glTF extensions used somewhere in this asset
  78427. */
  78428. extensionsUsed?: string[];
  78429. /**
  78430. * Names of glTF extensions required to properly load this asset
  78431. */
  78432. extensionsRequired?: string[];
  78433. /**
  78434. * An array of images. An image defines data used to create a texture
  78435. */
  78436. images?: IImage[];
  78437. /**
  78438. * An array of materials. A material defines the appearance of a primitive
  78439. */
  78440. materials?: IMaterial[];
  78441. /**
  78442. * An array of meshes. A mesh is a set of primitives to be rendered
  78443. */
  78444. meshes?: IMesh[];
  78445. /**
  78446. * An array of nodes
  78447. */
  78448. nodes?: INode[];
  78449. /**
  78450. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78451. */
  78452. samplers?: ISampler[];
  78453. /**
  78454. * The index of the default scene
  78455. */
  78456. scene?: number;
  78457. /**
  78458. * An array of scenes
  78459. */
  78460. scenes?: IScene[];
  78461. /**
  78462. * An array of skins. A skin is defined by joints and matrices
  78463. */
  78464. skins?: ISkin[];
  78465. /**
  78466. * An array of textures
  78467. */
  78468. textures?: ITexture[];
  78469. }
  78470. /**
  78471. * The glTF validation results
  78472. * @ignore
  78473. */
  78474. interface IGLTFValidationResults {
  78475. info: {
  78476. generator: string;
  78477. hasAnimations: boolean;
  78478. hasDefaultScene: boolean;
  78479. hasMaterials: boolean;
  78480. hasMorphTargets: boolean;
  78481. hasSkins: boolean;
  78482. hasTextures: boolean;
  78483. maxAttributesUsed: number;
  78484. primitivesCount: number
  78485. };
  78486. issues: {
  78487. messages: Array<string>;
  78488. numErrors: number;
  78489. numHints: number;
  78490. numInfos: number;
  78491. numWarnings: number;
  78492. truncated: boolean
  78493. };
  78494. mimeType: string;
  78495. uri: string;
  78496. validatedAt: string;
  78497. validatorVersion: string;
  78498. }
  78499. /**
  78500. * The glTF validation options
  78501. */
  78502. interface IGLTFValidationOptions {
  78503. /** Uri to use */
  78504. uri?: string;
  78505. /** Function used to load external resources */
  78506. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78507. /** Boolean indicating that we need to validate accessor data */
  78508. validateAccessorData?: boolean;
  78509. /** max number of issues allowed */
  78510. maxIssues?: number;
  78511. /** Ignored issues */
  78512. ignoredIssues?: Array<string>;
  78513. /** Value to override severy settings */
  78514. severityOverrides?: Object;
  78515. }
  78516. /**
  78517. * The glTF validator object
  78518. * @ignore
  78519. */
  78520. interface IGLTFValidator {
  78521. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78522. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78523. }
  78524. }
  78525. declare module BABYLON {
  78526. /** @hidden */
  78527. export var cellPixelShader: {
  78528. name: string;
  78529. shader: string;
  78530. };
  78531. }
  78532. declare module BABYLON {
  78533. /** @hidden */
  78534. export var cellVertexShader: {
  78535. name: string;
  78536. shader: string;
  78537. };
  78538. }
  78539. declare module BABYLON {
  78540. export class CellMaterial extends BABYLON.PushMaterial {
  78541. private _diffuseTexture;
  78542. diffuseTexture: BABYLON.BaseTexture;
  78543. diffuseColor: BABYLON.Color3;
  78544. _computeHighLevel: boolean;
  78545. computeHighLevel: boolean;
  78546. private _disableLighting;
  78547. disableLighting: boolean;
  78548. private _maxSimultaneousLights;
  78549. maxSimultaneousLights: number;
  78550. private _renderId;
  78551. constructor(name: string, scene: BABYLON.Scene);
  78552. needAlphaBlending(): boolean;
  78553. needAlphaTesting(): boolean;
  78554. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78555. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78556. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78557. getAnimatables(): BABYLON.IAnimatable[];
  78558. getActiveTextures(): BABYLON.BaseTexture[];
  78559. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78560. dispose(forceDisposeEffect?: boolean): void;
  78561. getClassName(): string;
  78562. clone(name: string): CellMaterial;
  78563. serialize(): any;
  78564. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78565. }
  78566. }
  78567. declare module BABYLON {
  78568. export class CustomShaderStructure {
  78569. FragmentStore: string;
  78570. VertexStore: string;
  78571. constructor();
  78572. }
  78573. export class ShaderSpecialParts {
  78574. constructor();
  78575. Fragment_Begin: string;
  78576. Fragment_Definitions: string;
  78577. Fragment_MainBegin: string;
  78578. Fragment_Custom_Diffuse: string;
  78579. Fragment_Before_Lights: string;
  78580. Fragment_Before_Fog: string;
  78581. Fragment_Custom_Alpha: string;
  78582. Fragment_Before_FragColor: string;
  78583. Vertex_Begin: string;
  78584. Vertex_Definitions: string;
  78585. Vertex_MainBegin: string;
  78586. Vertex_Before_PositionUpdated: string;
  78587. Vertex_Before_NormalUpdated: string;
  78588. Vertex_MainEnd: string;
  78589. }
  78590. export class CustomMaterial extends BABYLON.StandardMaterial {
  78591. static ShaderIndexer: number;
  78592. CustomParts: ShaderSpecialParts;
  78593. _isCreatedShader: boolean;
  78594. _createdShaderName: string;
  78595. _customUniform: string[];
  78596. _newUniforms: string[];
  78597. _newUniformInstances: any[];
  78598. _newSamplerInstances: BABYLON.Texture[];
  78599. FragmentShader: string;
  78600. VertexShader: string;
  78601. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78602. ReviewUniform(name: string, arr: string[]): string[];
  78603. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78604. constructor(name: string, scene: BABYLON.Scene);
  78605. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78606. Fragment_Begin(shaderPart: string): CustomMaterial;
  78607. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78608. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78609. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78610. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78611. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78612. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78613. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78614. Vertex_Begin(shaderPart: string): CustomMaterial;
  78615. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78616. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78617. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78618. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78619. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78620. }
  78621. }
  78622. declare module BABYLON {
  78623. export class ShaderAlebdoParts {
  78624. constructor();
  78625. Fragment_Begin: string;
  78626. Fragment_Definitions: string;
  78627. Fragment_MainBegin: string;
  78628. Fragment_Custom_Albedo: string;
  78629. Fragment_Before_Lights: string;
  78630. Fragment_Custom_MetallicRoughness: string;
  78631. Fragment_Custom_MicroSurface: string;
  78632. Fragment_Before_Fog: string;
  78633. Fragment_Custom_Alpha: string;
  78634. Fragment_Before_FragColor: string;
  78635. Vertex_Begin: string;
  78636. Vertex_Definitions: string;
  78637. Vertex_MainBegin: string;
  78638. Vertex_Before_PositionUpdated: string;
  78639. Vertex_Before_NormalUpdated: string;
  78640. Vertex_MainEnd: string;
  78641. }
  78642. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78643. static ShaderIndexer: number;
  78644. CustomParts: ShaderAlebdoParts;
  78645. _isCreatedShader: boolean;
  78646. _createdShaderName: string;
  78647. _customUniform: string[];
  78648. _newUniforms: string[];
  78649. _newUniformInstances: any[];
  78650. _newSamplerInstances: BABYLON.Texture[];
  78651. FragmentShader: string;
  78652. VertexShader: string;
  78653. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78654. ReviewUniform(name: string, arr: string[]): string[];
  78655. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78656. constructor(name: string, scene: BABYLON.Scene);
  78657. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78658. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78659. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78660. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78661. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78662. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78663. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78664. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78665. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78666. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78667. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78668. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78669. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78670. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78671. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78672. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78673. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78674. }
  78675. }
  78676. declare module BABYLON {
  78677. /** @hidden */
  78678. export var firePixelShader: {
  78679. name: string;
  78680. shader: string;
  78681. };
  78682. }
  78683. declare module BABYLON {
  78684. /** @hidden */
  78685. export var fireVertexShader: {
  78686. name: string;
  78687. shader: string;
  78688. };
  78689. }
  78690. declare module BABYLON {
  78691. export class FireMaterial extends BABYLON.PushMaterial {
  78692. private _diffuseTexture;
  78693. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78694. private _distortionTexture;
  78695. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78696. private _opacityTexture;
  78697. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78698. diffuseColor: BABYLON.Color3;
  78699. speed: number;
  78700. private _scaledDiffuse;
  78701. private _renderId;
  78702. private _lastTime;
  78703. constructor(name: string, scene: BABYLON.Scene);
  78704. needAlphaBlending(): boolean;
  78705. needAlphaTesting(): boolean;
  78706. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78707. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78708. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78709. getAnimatables(): BABYLON.IAnimatable[];
  78710. getActiveTextures(): BABYLON.BaseTexture[];
  78711. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78712. getClassName(): string;
  78713. dispose(forceDisposeEffect?: boolean): void;
  78714. clone(name: string): FireMaterial;
  78715. serialize(): any;
  78716. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78717. }
  78718. }
  78719. declare module BABYLON {
  78720. /** @hidden */
  78721. export var furPixelShader: {
  78722. name: string;
  78723. shader: string;
  78724. };
  78725. }
  78726. declare module BABYLON {
  78727. /** @hidden */
  78728. export var furVertexShader: {
  78729. name: string;
  78730. shader: string;
  78731. };
  78732. }
  78733. declare module BABYLON {
  78734. export class FurMaterial extends BABYLON.PushMaterial {
  78735. private _diffuseTexture;
  78736. diffuseTexture: BABYLON.BaseTexture;
  78737. private _heightTexture;
  78738. heightTexture: BABYLON.BaseTexture;
  78739. diffuseColor: BABYLON.Color3;
  78740. furLength: number;
  78741. furAngle: number;
  78742. furColor: BABYLON.Color3;
  78743. furOffset: number;
  78744. furSpacing: number;
  78745. furGravity: BABYLON.Vector3;
  78746. furSpeed: number;
  78747. furDensity: number;
  78748. furOcclusion: number;
  78749. furTexture: BABYLON.DynamicTexture;
  78750. private _disableLighting;
  78751. disableLighting: boolean;
  78752. private _maxSimultaneousLights;
  78753. maxSimultaneousLights: number;
  78754. highLevelFur: boolean;
  78755. _meshes: BABYLON.AbstractMesh[];
  78756. private _renderId;
  78757. private _furTime;
  78758. constructor(name: string, scene: BABYLON.Scene);
  78759. get furTime(): number;
  78760. set furTime(furTime: number);
  78761. needAlphaBlending(): boolean;
  78762. needAlphaTesting(): boolean;
  78763. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78764. updateFur(): void;
  78765. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78766. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78767. getAnimatables(): BABYLON.IAnimatable[];
  78768. getActiveTextures(): BABYLON.BaseTexture[];
  78769. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78770. dispose(forceDisposeEffect?: boolean): void;
  78771. clone(name: string): FurMaterial;
  78772. serialize(): any;
  78773. getClassName(): string;
  78774. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78775. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78776. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78777. }
  78778. }
  78779. declare module BABYLON {
  78780. /** @hidden */
  78781. export var gradientPixelShader: {
  78782. name: string;
  78783. shader: string;
  78784. };
  78785. }
  78786. declare module BABYLON {
  78787. /** @hidden */
  78788. export var gradientVertexShader: {
  78789. name: string;
  78790. shader: string;
  78791. };
  78792. }
  78793. declare module BABYLON {
  78794. export class GradientMaterial extends BABYLON.PushMaterial {
  78795. private _maxSimultaneousLights;
  78796. maxSimultaneousLights: number;
  78797. topColor: BABYLON.Color3;
  78798. topColorAlpha: number;
  78799. bottomColor: BABYLON.Color3;
  78800. bottomColorAlpha: number;
  78801. offset: number;
  78802. scale: number;
  78803. smoothness: number;
  78804. private _disableLighting;
  78805. disableLighting: boolean;
  78806. private _renderId;
  78807. constructor(name: string, scene: BABYLON.Scene);
  78808. needAlphaBlending(): boolean;
  78809. needAlphaTesting(): boolean;
  78810. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78811. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78812. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78813. getAnimatables(): BABYLON.IAnimatable[];
  78814. dispose(forceDisposeEffect?: boolean): void;
  78815. clone(name: string): GradientMaterial;
  78816. serialize(): any;
  78817. getClassName(): string;
  78818. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78819. }
  78820. }
  78821. declare module BABYLON {
  78822. /** @hidden */
  78823. export var gridPixelShader: {
  78824. name: string;
  78825. shader: string;
  78826. };
  78827. }
  78828. declare module BABYLON {
  78829. /** @hidden */
  78830. export var gridVertexShader: {
  78831. name: string;
  78832. shader: string;
  78833. };
  78834. }
  78835. declare module BABYLON {
  78836. /**
  78837. * The grid materials allows you to wrap any shape with a grid.
  78838. * Colors are customizable.
  78839. */
  78840. export class GridMaterial extends BABYLON.PushMaterial {
  78841. /**
  78842. * Main color of the grid (e.g. between lines)
  78843. */
  78844. mainColor: BABYLON.Color3;
  78845. /**
  78846. * Color of the grid lines.
  78847. */
  78848. lineColor: BABYLON.Color3;
  78849. /**
  78850. * The scale of the grid compared to unit.
  78851. */
  78852. gridRatio: number;
  78853. /**
  78854. * Allows setting an offset for the grid lines.
  78855. */
  78856. gridOffset: BABYLON.Vector3;
  78857. /**
  78858. * The frequency of thicker lines.
  78859. */
  78860. majorUnitFrequency: number;
  78861. /**
  78862. * The visibility of minor units in the grid.
  78863. */
  78864. minorUnitVisibility: number;
  78865. /**
  78866. * The grid opacity outside of the lines.
  78867. */
  78868. opacity: number;
  78869. /**
  78870. * Determine RBG output is premultiplied by alpha value.
  78871. */
  78872. preMultiplyAlpha: boolean;
  78873. private _opacityTexture;
  78874. opacityTexture: BABYLON.BaseTexture;
  78875. private _gridControl;
  78876. private _renderId;
  78877. /**
  78878. * constructor
  78879. * @param name The name given to the material in order to identify it afterwards.
  78880. * @param scene The scene the material is used in.
  78881. */
  78882. constructor(name: string, scene: BABYLON.Scene);
  78883. /**
  78884. * Returns wehter or not the grid requires alpha blending.
  78885. */
  78886. needAlphaBlending(): boolean;
  78887. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78888. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78889. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78890. /**
  78891. * Dispose the material and its associated resources.
  78892. * @param forceDisposeEffect will also dispose the used effect when true
  78893. */
  78894. dispose(forceDisposeEffect?: boolean): void;
  78895. clone(name: string): GridMaterial;
  78896. serialize(): any;
  78897. getClassName(): string;
  78898. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78899. }
  78900. }
  78901. declare module BABYLON {
  78902. /** @hidden */
  78903. export var lavaPixelShader: {
  78904. name: string;
  78905. shader: string;
  78906. };
  78907. }
  78908. declare module BABYLON {
  78909. /** @hidden */
  78910. export var lavaVertexShader: {
  78911. name: string;
  78912. shader: string;
  78913. };
  78914. }
  78915. declare module BABYLON {
  78916. export class LavaMaterial extends BABYLON.PushMaterial {
  78917. private _diffuseTexture;
  78918. diffuseTexture: BABYLON.BaseTexture;
  78919. noiseTexture: BABYLON.BaseTexture;
  78920. fogColor: BABYLON.Color3;
  78921. speed: number;
  78922. movingSpeed: number;
  78923. lowFrequencySpeed: number;
  78924. fogDensity: number;
  78925. private _lastTime;
  78926. diffuseColor: BABYLON.Color3;
  78927. private _disableLighting;
  78928. disableLighting: boolean;
  78929. private _unlit;
  78930. unlit: boolean;
  78931. private _maxSimultaneousLights;
  78932. maxSimultaneousLights: number;
  78933. private _scaledDiffuse;
  78934. private _renderId;
  78935. constructor(name: string, scene: BABYLON.Scene);
  78936. needAlphaBlending(): boolean;
  78937. needAlphaTesting(): boolean;
  78938. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78939. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78940. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78941. getAnimatables(): BABYLON.IAnimatable[];
  78942. getActiveTextures(): BABYLON.BaseTexture[];
  78943. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78944. dispose(forceDisposeEffect?: boolean): void;
  78945. clone(name: string): LavaMaterial;
  78946. serialize(): any;
  78947. getClassName(): string;
  78948. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78949. }
  78950. }
  78951. declare module BABYLON {
  78952. /** @hidden */
  78953. export var mixPixelShader: {
  78954. name: string;
  78955. shader: string;
  78956. };
  78957. }
  78958. declare module BABYLON {
  78959. /** @hidden */
  78960. export var mixVertexShader: {
  78961. name: string;
  78962. shader: string;
  78963. };
  78964. }
  78965. declare module BABYLON {
  78966. export class MixMaterial extends BABYLON.PushMaterial {
  78967. /**
  78968. * Mix textures
  78969. */
  78970. private _mixTexture1;
  78971. mixTexture1: BABYLON.BaseTexture;
  78972. private _mixTexture2;
  78973. mixTexture2: BABYLON.BaseTexture;
  78974. /**
  78975. * Diffuse textures
  78976. */
  78977. private _diffuseTexture1;
  78978. diffuseTexture1: BABYLON.Texture;
  78979. private _diffuseTexture2;
  78980. diffuseTexture2: BABYLON.Texture;
  78981. private _diffuseTexture3;
  78982. diffuseTexture3: BABYLON.Texture;
  78983. private _diffuseTexture4;
  78984. diffuseTexture4: BABYLON.Texture;
  78985. private _diffuseTexture5;
  78986. diffuseTexture5: BABYLON.Texture;
  78987. private _diffuseTexture6;
  78988. diffuseTexture6: BABYLON.Texture;
  78989. private _diffuseTexture7;
  78990. diffuseTexture7: BABYLON.Texture;
  78991. private _diffuseTexture8;
  78992. diffuseTexture8: BABYLON.Texture;
  78993. /**
  78994. * Uniforms
  78995. */
  78996. diffuseColor: BABYLON.Color3;
  78997. specularColor: BABYLON.Color3;
  78998. specularPower: number;
  78999. private _disableLighting;
  79000. disableLighting: boolean;
  79001. private _maxSimultaneousLights;
  79002. maxSimultaneousLights: number;
  79003. private _renderId;
  79004. constructor(name: string, scene: BABYLON.Scene);
  79005. needAlphaBlending(): boolean;
  79006. needAlphaTesting(): boolean;
  79007. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79008. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79009. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79010. getAnimatables(): BABYLON.IAnimatable[];
  79011. getActiveTextures(): BABYLON.BaseTexture[];
  79012. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79013. dispose(forceDisposeEffect?: boolean): void;
  79014. clone(name: string): MixMaterial;
  79015. serialize(): any;
  79016. getClassName(): string;
  79017. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  79018. }
  79019. }
  79020. declare module BABYLON {
  79021. /** @hidden */
  79022. export var normalPixelShader: {
  79023. name: string;
  79024. shader: string;
  79025. };
  79026. }
  79027. declare module BABYLON {
  79028. /** @hidden */
  79029. export var normalVertexShader: {
  79030. name: string;
  79031. shader: string;
  79032. };
  79033. }
  79034. declare module BABYLON {
  79035. export class NormalMaterial extends BABYLON.PushMaterial {
  79036. private _diffuseTexture;
  79037. diffuseTexture: BABYLON.BaseTexture;
  79038. diffuseColor: BABYLON.Color3;
  79039. private _disableLighting;
  79040. disableLighting: boolean;
  79041. private _maxSimultaneousLights;
  79042. maxSimultaneousLights: number;
  79043. private _renderId;
  79044. constructor(name: string, scene: BABYLON.Scene);
  79045. needAlphaBlending(): boolean;
  79046. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  79047. needAlphaTesting(): boolean;
  79048. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79049. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79050. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79051. getAnimatables(): BABYLON.IAnimatable[];
  79052. getActiveTextures(): BABYLON.BaseTexture[];
  79053. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79054. dispose(forceDisposeEffect?: boolean): void;
  79055. clone(name: string): NormalMaterial;
  79056. serialize(): any;
  79057. getClassName(): string;
  79058. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  79059. }
  79060. }
  79061. declare module BABYLON {
  79062. /** @hidden */
  79063. export var shadowOnlyPixelShader: {
  79064. name: string;
  79065. shader: string;
  79066. };
  79067. }
  79068. declare module BABYLON {
  79069. /** @hidden */
  79070. export var shadowOnlyVertexShader: {
  79071. name: string;
  79072. shader: string;
  79073. };
  79074. }
  79075. declare module BABYLON {
  79076. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  79077. private _renderId;
  79078. private _activeLight;
  79079. constructor(name: string, scene: BABYLON.Scene);
  79080. shadowColor: BABYLON.Color3;
  79081. needAlphaBlending(): boolean;
  79082. needAlphaTesting(): boolean;
  79083. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79084. get activeLight(): BABYLON.IShadowLight;
  79085. set activeLight(light: BABYLON.IShadowLight);
  79086. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79087. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79088. clone(name: string): ShadowOnlyMaterial;
  79089. serialize(): any;
  79090. getClassName(): string;
  79091. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  79092. }
  79093. }
  79094. declare module BABYLON {
  79095. /** @hidden */
  79096. export var simplePixelShader: {
  79097. name: string;
  79098. shader: string;
  79099. };
  79100. }
  79101. declare module BABYLON {
  79102. /** @hidden */
  79103. export var simpleVertexShader: {
  79104. name: string;
  79105. shader: string;
  79106. };
  79107. }
  79108. declare module BABYLON {
  79109. export class SimpleMaterial extends BABYLON.PushMaterial {
  79110. private _diffuseTexture;
  79111. diffuseTexture: BABYLON.BaseTexture;
  79112. diffuseColor: BABYLON.Color3;
  79113. private _disableLighting;
  79114. disableLighting: boolean;
  79115. private _maxSimultaneousLights;
  79116. maxSimultaneousLights: number;
  79117. private _renderId;
  79118. constructor(name: string, scene: BABYLON.Scene);
  79119. needAlphaBlending(): boolean;
  79120. needAlphaTesting(): boolean;
  79121. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79122. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79123. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79124. getAnimatables(): BABYLON.IAnimatable[];
  79125. getActiveTextures(): BABYLON.BaseTexture[];
  79126. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79127. dispose(forceDisposeEffect?: boolean): void;
  79128. clone(name: string): SimpleMaterial;
  79129. serialize(): any;
  79130. getClassName(): string;
  79131. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  79132. }
  79133. }
  79134. declare module BABYLON {
  79135. /** @hidden */
  79136. export var skyPixelShader: {
  79137. name: string;
  79138. shader: string;
  79139. };
  79140. }
  79141. declare module BABYLON {
  79142. /** @hidden */
  79143. export var skyVertexShader: {
  79144. name: string;
  79145. shader: string;
  79146. };
  79147. }
  79148. declare module BABYLON {
  79149. /**
  79150. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79151. * @see https://doc.babylonjs.com/extensions/sky
  79152. */
  79153. export class SkyMaterial extends BABYLON.PushMaterial {
  79154. /**
  79155. * Defines the overall luminance of sky in interval ]0, 1[.
  79156. */
  79157. luminance: number;
  79158. /**
  79159. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79160. */
  79161. turbidity: number;
  79162. /**
  79163. * Defines the sky appearance (light intensity).
  79164. */
  79165. rayleigh: number;
  79166. /**
  79167. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79168. */
  79169. mieCoefficient: number;
  79170. /**
  79171. * Defines the amount of haze particles following the Mie scattering theory.
  79172. */
  79173. mieDirectionalG: number;
  79174. /**
  79175. * Defines the distance of the sun according to the active scene camera.
  79176. */
  79177. distance: number;
  79178. /**
  79179. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79180. * "inclined".
  79181. */
  79182. inclination: number;
  79183. /**
  79184. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79185. * an object direction and a reference direction.
  79186. */
  79187. azimuth: number;
  79188. /**
  79189. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79190. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79191. */
  79192. sunPosition: BABYLON.Vector3;
  79193. /**
  79194. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79195. * .sunPosition property.
  79196. */
  79197. useSunPosition: boolean;
  79198. /**
  79199. * Defines an offset vector used to get a horizon offset.
  79200. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79201. */
  79202. cameraOffset: BABYLON.Vector3;
  79203. private _cameraPosition;
  79204. private _renderId;
  79205. /**
  79206. * Instantiates a new sky material.
  79207. * This material allows to create dynamic and texture free
  79208. * effects for skyboxes by taking care of the atmosphere state.
  79209. * @see https://doc.babylonjs.com/extensions/sky
  79210. * @param name Define the name of the material in the scene
  79211. * @param scene Define the scene the material belong to
  79212. */
  79213. constructor(name: string, scene: BABYLON.Scene);
  79214. /**
  79215. * Specifies if the material will require alpha blending
  79216. * @returns a boolean specifying if alpha blending is needed
  79217. */
  79218. needAlphaBlending(): boolean;
  79219. /**
  79220. * Specifies if this material should be rendered in alpha test mode
  79221. * @returns false as the sky material doesn't need alpha testing.
  79222. */
  79223. needAlphaTesting(): boolean;
  79224. /**
  79225. * Get the texture used for alpha test purpose.
  79226. * @returns null as the sky material has no texture.
  79227. */
  79228. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79229. /**
  79230. * Get if the submesh is ready to be used and all its information available.
  79231. * Child classes can use it to update shaders
  79232. * @param mesh defines the mesh to check
  79233. * @param subMesh defines which submesh to check
  79234. * @param useInstances specifies that instances should be used
  79235. * @returns a boolean indicating that the submesh is ready or not
  79236. */
  79237. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79238. /**
  79239. * Binds the submesh to this material by preparing the effect and shader to draw
  79240. * @param world defines the world transformation matrix
  79241. * @param mesh defines the mesh containing the submesh
  79242. * @param subMesh defines the submesh to bind the material to
  79243. */
  79244. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79245. /**
  79246. * Get the list of animatables in the material.
  79247. * @returns the list of animatables object used in the material
  79248. */
  79249. getAnimatables(): BABYLON.IAnimatable[];
  79250. /**
  79251. * Disposes the material
  79252. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79253. */
  79254. dispose(forceDisposeEffect?: boolean): void;
  79255. /**
  79256. * Makes a duplicate of the material, and gives it a new name
  79257. * @param name defines the new name for the duplicated material
  79258. * @returns the cloned material
  79259. */
  79260. clone(name: string): SkyMaterial;
  79261. /**
  79262. * Serializes this material in a JSON representation
  79263. * @returns the serialized material object
  79264. */
  79265. serialize(): any;
  79266. /**
  79267. * Gets the current class name of the material e.g. "SkyMaterial"
  79268. * Mainly use in serialization.
  79269. * @returns the class name
  79270. */
  79271. getClassName(): string;
  79272. /**
  79273. * Creates a sky material from parsed material data
  79274. * @param source defines the JSON representation of the material
  79275. * @param scene defines the hosting scene
  79276. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79277. * @returns a new sky material
  79278. */
  79279. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79280. }
  79281. }
  79282. declare module BABYLON {
  79283. /** @hidden */
  79284. export var terrainPixelShader: {
  79285. name: string;
  79286. shader: string;
  79287. };
  79288. }
  79289. declare module BABYLON {
  79290. /** @hidden */
  79291. export var terrainVertexShader: {
  79292. name: string;
  79293. shader: string;
  79294. };
  79295. }
  79296. declare module BABYLON {
  79297. export class TerrainMaterial extends BABYLON.PushMaterial {
  79298. private _mixTexture;
  79299. mixTexture: BABYLON.BaseTexture;
  79300. private _diffuseTexture1;
  79301. diffuseTexture1: BABYLON.Texture;
  79302. private _diffuseTexture2;
  79303. diffuseTexture2: BABYLON.Texture;
  79304. private _diffuseTexture3;
  79305. diffuseTexture3: BABYLON.Texture;
  79306. private _bumpTexture1;
  79307. bumpTexture1: BABYLON.Texture;
  79308. private _bumpTexture2;
  79309. bumpTexture2: BABYLON.Texture;
  79310. private _bumpTexture3;
  79311. bumpTexture3: BABYLON.Texture;
  79312. diffuseColor: BABYLON.Color3;
  79313. specularColor: BABYLON.Color3;
  79314. specularPower: number;
  79315. private _disableLighting;
  79316. disableLighting: boolean;
  79317. private _maxSimultaneousLights;
  79318. maxSimultaneousLights: number;
  79319. private _renderId;
  79320. constructor(name: string, scene: BABYLON.Scene);
  79321. needAlphaBlending(): boolean;
  79322. needAlphaTesting(): boolean;
  79323. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79324. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79325. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79326. getAnimatables(): BABYLON.IAnimatable[];
  79327. getActiveTextures(): BABYLON.BaseTexture[];
  79328. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79329. dispose(forceDisposeEffect?: boolean): void;
  79330. clone(name: string): TerrainMaterial;
  79331. serialize(): any;
  79332. getClassName(): string;
  79333. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79334. }
  79335. }
  79336. declare module BABYLON {
  79337. /** @hidden */
  79338. export var triplanarPixelShader: {
  79339. name: string;
  79340. shader: string;
  79341. };
  79342. }
  79343. declare module BABYLON {
  79344. /** @hidden */
  79345. export var triplanarVertexShader: {
  79346. name: string;
  79347. shader: string;
  79348. };
  79349. }
  79350. declare module BABYLON {
  79351. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79352. mixTexture: BABYLON.BaseTexture;
  79353. private _diffuseTextureX;
  79354. diffuseTextureX: BABYLON.BaseTexture;
  79355. private _diffuseTextureY;
  79356. diffuseTextureY: BABYLON.BaseTexture;
  79357. private _diffuseTextureZ;
  79358. diffuseTextureZ: BABYLON.BaseTexture;
  79359. private _normalTextureX;
  79360. normalTextureX: BABYLON.BaseTexture;
  79361. private _normalTextureY;
  79362. normalTextureY: BABYLON.BaseTexture;
  79363. private _normalTextureZ;
  79364. normalTextureZ: BABYLON.BaseTexture;
  79365. tileSize: number;
  79366. diffuseColor: BABYLON.Color3;
  79367. specularColor: BABYLON.Color3;
  79368. specularPower: number;
  79369. private _disableLighting;
  79370. disableLighting: boolean;
  79371. private _maxSimultaneousLights;
  79372. maxSimultaneousLights: number;
  79373. private _renderId;
  79374. constructor(name: string, scene: BABYLON.Scene);
  79375. needAlphaBlending(): boolean;
  79376. needAlphaTesting(): boolean;
  79377. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79378. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79379. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79380. getAnimatables(): BABYLON.IAnimatable[];
  79381. getActiveTextures(): BABYLON.BaseTexture[];
  79382. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79383. dispose(forceDisposeEffect?: boolean): void;
  79384. clone(name: string): TriPlanarMaterial;
  79385. serialize(): any;
  79386. getClassName(): string;
  79387. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79388. }
  79389. }
  79390. declare module BABYLON {
  79391. /** @hidden */
  79392. export var waterPixelShader: {
  79393. name: string;
  79394. shader: string;
  79395. };
  79396. }
  79397. declare module BABYLON {
  79398. /** @hidden */
  79399. export var waterVertexShader: {
  79400. name: string;
  79401. shader: string;
  79402. };
  79403. }
  79404. declare module BABYLON {
  79405. export class WaterMaterial extends BABYLON.PushMaterial {
  79406. renderTargetSize: BABYLON.Vector2;
  79407. private _bumpTexture;
  79408. bumpTexture: BABYLON.BaseTexture;
  79409. diffuseColor: BABYLON.Color3;
  79410. specularColor: BABYLON.Color3;
  79411. specularPower: number;
  79412. private _disableLighting;
  79413. disableLighting: boolean;
  79414. private _maxSimultaneousLights;
  79415. maxSimultaneousLights: number;
  79416. /**
  79417. * @param {number}: Represents the wind force
  79418. */
  79419. windForce: number;
  79420. /**
  79421. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79422. */
  79423. windDirection: BABYLON.Vector2;
  79424. /**
  79425. * @param {number}: Wave height, represents the height of the waves
  79426. */
  79427. waveHeight: number;
  79428. /**
  79429. * @param {number}: Bump height, represents the bump height related to the bump map
  79430. */
  79431. bumpHeight: number;
  79432. /**
  79433. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79434. */
  79435. private _bumpSuperimpose;
  79436. bumpSuperimpose: boolean;
  79437. /**
  79438. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79439. */
  79440. private _fresnelSeparate;
  79441. fresnelSeparate: boolean;
  79442. /**
  79443. * @param {boolean}: bump Waves modify the reflection.
  79444. */
  79445. private _bumpAffectsReflection;
  79446. bumpAffectsReflection: boolean;
  79447. /**
  79448. * @param {number}: The water color blended with the refraction (near)
  79449. */
  79450. waterColor: BABYLON.Color3;
  79451. /**
  79452. * @param {number}: The blend factor related to the water color
  79453. */
  79454. colorBlendFactor: number;
  79455. /**
  79456. * @param {number}: The water color blended with the reflection (far)
  79457. */
  79458. waterColor2: BABYLON.Color3;
  79459. /**
  79460. * @param {number}: The blend factor related to the water color (reflection, far)
  79461. */
  79462. colorBlendFactor2: number;
  79463. /**
  79464. * @param {number}: Represents the maximum length of a wave
  79465. */
  79466. waveLength: number;
  79467. /**
  79468. * @param {number}: Defines the waves speed
  79469. */
  79470. waveSpeed: number;
  79471. /**
  79472. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79473. * will avoid calculating useless pixels in the pixel shader of the water material.
  79474. */
  79475. disableClipPlane: boolean;
  79476. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79477. private _mesh;
  79478. private _refractionRTT;
  79479. private _reflectionRTT;
  79480. private _reflectionTransform;
  79481. private _lastTime;
  79482. private _lastDeltaTime;
  79483. private _renderId;
  79484. private _useLogarithmicDepth;
  79485. private _waitingRenderList;
  79486. private _imageProcessingConfiguration;
  79487. private _imageProcessingObserver;
  79488. /**
  79489. * Gets a boolean indicating that current material needs to register RTT
  79490. */
  79491. get hasRenderTargetTextures(): boolean;
  79492. /**
  79493. * Constructor
  79494. */
  79495. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79496. get useLogarithmicDepth(): boolean;
  79497. set useLogarithmicDepth(value: boolean);
  79498. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79499. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79500. addToRenderList(node: any): void;
  79501. enableRenderTargets(enable: boolean): void;
  79502. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79503. get renderTargetsEnabled(): boolean;
  79504. needAlphaBlending(): boolean;
  79505. needAlphaTesting(): boolean;
  79506. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79507. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79508. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79509. private _createRenderTargets;
  79510. getAnimatables(): BABYLON.IAnimatable[];
  79511. getActiveTextures(): BABYLON.BaseTexture[];
  79512. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79513. dispose(forceDisposeEffect?: boolean): void;
  79514. clone(name: string): WaterMaterial;
  79515. serialize(): any;
  79516. getClassName(): string;
  79517. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79518. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79519. }
  79520. }
  79521. declare module BABYLON {
  79522. /** @hidden */
  79523. export var asciiartPixelShader: {
  79524. name: string;
  79525. shader: string;
  79526. };
  79527. }
  79528. declare module BABYLON {
  79529. /**
  79530. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79531. *
  79532. * It basically takes care rendering the font front the given font size to a texture.
  79533. * This is used later on in the postprocess.
  79534. */
  79535. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79536. private _font;
  79537. private _text;
  79538. private _charSize;
  79539. /**
  79540. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79541. */
  79542. get charSize(): number;
  79543. /**
  79544. * Create a new instance of the Ascii Art FontTexture class
  79545. * @param name the name of the texture
  79546. * @param font the font to use, use the W3C CSS notation
  79547. * @param text the caracter set to use in the rendering.
  79548. * @param scene the scene that owns the texture
  79549. */
  79550. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79551. /**
  79552. * Gets the max char width of a font.
  79553. * @param font the font to use, use the W3C CSS notation
  79554. * @return the max char width
  79555. */
  79556. private getFontWidth;
  79557. /**
  79558. * Gets the max char height of a font.
  79559. * @param font the font to use, use the W3C CSS notation
  79560. * @return the max char height
  79561. */
  79562. private getFontHeight;
  79563. /**
  79564. * Clones the current AsciiArtTexture.
  79565. * @return the clone of the texture.
  79566. */
  79567. clone(): AsciiArtFontTexture;
  79568. /**
  79569. * Parses a json object representing the texture and returns an instance of it.
  79570. * @param source the source JSON representation
  79571. * @param scene the scene to create the texture for
  79572. * @return the parsed texture
  79573. */
  79574. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79575. }
  79576. /**
  79577. * Option available in the Ascii Art Post Process.
  79578. */
  79579. export interface IAsciiArtPostProcessOptions {
  79580. /**
  79581. * The font to use following the w3c font definition.
  79582. */
  79583. font?: string;
  79584. /**
  79585. * The character set to use in the postprocess.
  79586. */
  79587. characterSet?: string;
  79588. /**
  79589. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79590. * This number is defined between 0 and 1;
  79591. */
  79592. mixToTile?: number;
  79593. /**
  79594. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79595. * This number is defined between 0 and 1;
  79596. */
  79597. mixToNormal?: number;
  79598. }
  79599. /**
  79600. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79601. *
  79602. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79603. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79604. */
  79605. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79606. /**
  79607. * The font texture used to render the char in the post process.
  79608. */
  79609. private _asciiArtFontTexture;
  79610. /**
  79611. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79612. * This number is defined between 0 and 1;
  79613. */
  79614. mixToTile: number;
  79615. /**
  79616. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79617. * This number is defined between 0 and 1;
  79618. */
  79619. mixToNormal: number;
  79620. /**
  79621. * Instantiates a new Ascii Art Post Process.
  79622. * @param name the name to give to the postprocess
  79623. * @camera the camera to apply the post process to.
  79624. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79625. */
  79626. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79627. }
  79628. }
  79629. declare module BABYLON {
  79630. /** @hidden */
  79631. export var digitalrainPixelShader: {
  79632. name: string;
  79633. shader: string;
  79634. };
  79635. }
  79636. declare module BABYLON {
  79637. /**
  79638. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79639. *
  79640. * It basically takes care rendering the font front the given font size to a texture.
  79641. * This is used later on in the postprocess.
  79642. */
  79643. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79644. private _font;
  79645. private _text;
  79646. private _charSize;
  79647. /**
  79648. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79649. */
  79650. get charSize(): number;
  79651. /**
  79652. * Create a new instance of the Digital Rain FontTexture class
  79653. * @param name the name of the texture
  79654. * @param font the font to use, use the W3C CSS notation
  79655. * @param text the caracter set to use in the rendering.
  79656. * @param scene the scene that owns the texture
  79657. */
  79658. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79659. /**
  79660. * Gets the max char width of a font.
  79661. * @param font the font to use, use the W3C CSS notation
  79662. * @return the max char width
  79663. */
  79664. private getFontWidth;
  79665. /**
  79666. * Gets the max char height of a font.
  79667. * @param font the font to use, use the W3C CSS notation
  79668. * @return the max char height
  79669. */
  79670. private getFontHeight;
  79671. /**
  79672. * Clones the current DigitalRainFontTexture.
  79673. * @return the clone of the texture.
  79674. */
  79675. clone(): DigitalRainFontTexture;
  79676. /**
  79677. * Parses a json object representing the texture and returns an instance of it.
  79678. * @param source the source JSON representation
  79679. * @param scene the scene to create the texture for
  79680. * @return the parsed texture
  79681. */
  79682. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79683. }
  79684. /**
  79685. * Option available in the Digital Rain Post Process.
  79686. */
  79687. export interface IDigitalRainPostProcessOptions {
  79688. /**
  79689. * The font to use following the w3c font definition.
  79690. */
  79691. font?: string;
  79692. /**
  79693. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79694. * This number is defined between 0 and 1;
  79695. */
  79696. mixToTile?: number;
  79697. /**
  79698. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79699. * This number is defined between 0 and 1;
  79700. */
  79701. mixToNormal?: number;
  79702. }
  79703. /**
  79704. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79705. *
  79706. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79707. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79708. */
  79709. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79710. /**
  79711. * The font texture used to render the char in the post process.
  79712. */
  79713. private _digitalRainFontTexture;
  79714. /**
  79715. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79716. * This number is defined between 0 and 1;
  79717. */
  79718. mixToTile: number;
  79719. /**
  79720. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79721. * This number is defined between 0 and 1;
  79722. */
  79723. mixToNormal: number;
  79724. /**
  79725. * Instantiates a new Digital Rain Post Process.
  79726. * @param name the name to give to the postprocess
  79727. * @camera the camera to apply the post process to.
  79728. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79729. */
  79730. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79731. }
  79732. }
  79733. declare module BABYLON {
  79734. /** @hidden */
  79735. export var brickProceduralTexturePixelShader: {
  79736. name: string;
  79737. shader: string;
  79738. };
  79739. }
  79740. declare module BABYLON {
  79741. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79742. private _numberOfBricksHeight;
  79743. private _numberOfBricksWidth;
  79744. private _jointColor;
  79745. private _brickColor;
  79746. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79747. updateShaderUniforms(): void;
  79748. get numberOfBricksHeight(): number;
  79749. set numberOfBricksHeight(value: number);
  79750. get numberOfBricksWidth(): number;
  79751. set numberOfBricksWidth(value: number);
  79752. get jointColor(): BABYLON.Color3;
  79753. set jointColor(value: BABYLON.Color3);
  79754. get brickColor(): BABYLON.Color3;
  79755. set brickColor(value: BABYLON.Color3);
  79756. /**
  79757. * Serializes this brick procedural texture
  79758. * @returns a serialized brick procedural texture object
  79759. */
  79760. serialize(): any;
  79761. /**
  79762. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79763. * @param parsedTexture defines parsed texture data
  79764. * @param scene defines the current scene
  79765. * @param rootUrl defines the root URL containing brick procedural texture information
  79766. * @returns a parsed Brick Procedural BABYLON.Texture
  79767. */
  79768. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79769. }
  79770. }
  79771. declare module BABYLON {
  79772. /** @hidden */
  79773. export var cloudProceduralTexturePixelShader: {
  79774. name: string;
  79775. shader: string;
  79776. };
  79777. }
  79778. declare module BABYLON {
  79779. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79780. private _skyColor;
  79781. private _cloudColor;
  79782. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79783. updateShaderUniforms(): void;
  79784. get skyColor(): BABYLON.Color4;
  79785. set skyColor(value: BABYLON.Color4);
  79786. get cloudColor(): BABYLON.Color4;
  79787. set cloudColor(value: BABYLON.Color4);
  79788. /**
  79789. * Serializes this cloud procedural texture
  79790. * @returns a serialized cloud procedural texture object
  79791. */
  79792. serialize(): any;
  79793. /**
  79794. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79795. * @param parsedTexture defines parsed texture data
  79796. * @param scene defines the current scene
  79797. * @param rootUrl defines the root URL containing cloud procedural texture information
  79798. * @returns a parsed Cloud Procedural BABYLON.Texture
  79799. */
  79800. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79801. }
  79802. }
  79803. declare module BABYLON {
  79804. /** @hidden */
  79805. export var fireProceduralTexturePixelShader: {
  79806. name: string;
  79807. shader: string;
  79808. };
  79809. }
  79810. declare module BABYLON {
  79811. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79812. private _time;
  79813. private _speed;
  79814. private _autoGenerateTime;
  79815. private _fireColors;
  79816. private _alphaThreshold;
  79817. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79818. updateShaderUniforms(): void;
  79819. render(useCameraPostProcess?: boolean): void;
  79820. static get PurpleFireColors(): BABYLON.Color3[];
  79821. static get GreenFireColors(): BABYLON.Color3[];
  79822. static get RedFireColors(): BABYLON.Color3[];
  79823. static get BlueFireColors(): BABYLON.Color3[];
  79824. get autoGenerateTime(): boolean;
  79825. set autoGenerateTime(value: boolean);
  79826. get fireColors(): BABYLON.Color3[];
  79827. set fireColors(value: BABYLON.Color3[]);
  79828. get time(): number;
  79829. set time(value: number);
  79830. get speed(): BABYLON.Vector2;
  79831. set speed(value: BABYLON.Vector2);
  79832. get alphaThreshold(): number;
  79833. set alphaThreshold(value: number);
  79834. /**
  79835. * Serializes this fire procedural texture
  79836. * @returns a serialized fire procedural texture object
  79837. */
  79838. serialize(): any;
  79839. /**
  79840. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79841. * @param parsedTexture defines parsed texture data
  79842. * @param scene defines the current scene
  79843. * @param rootUrl defines the root URL containing fire procedural texture information
  79844. * @returns a parsed Fire Procedural BABYLON.Texture
  79845. */
  79846. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79847. }
  79848. }
  79849. declare module BABYLON {
  79850. /** @hidden */
  79851. export var grassProceduralTexturePixelShader: {
  79852. name: string;
  79853. shader: string;
  79854. };
  79855. }
  79856. declare module BABYLON {
  79857. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79858. private _grassColors;
  79859. private _groundColor;
  79860. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79861. updateShaderUniforms(): void;
  79862. get grassColors(): BABYLON.Color3[];
  79863. set grassColors(value: BABYLON.Color3[]);
  79864. get groundColor(): BABYLON.Color3;
  79865. set groundColor(value: BABYLON.Color3);
  79866. /**
  79867. * Serializes this grass procedural texture
  79868. * @returns a serialized grass procedural texture object
  79869. */
  79870. serialize(): any;
  79871. /**
  79872. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79873. * @param parsedTexture defines parsed texture data
  79874. * @param scene defines the current scene
  79875. * @param rootUrl defines the root URL containing grass procedural texture information
  79876. * @returns a parsed Grass Procedural BABYLON.Texture
  79877. */
  79878. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79879. }
  79880. }
  79881. declare module BABYLON {
  79882. /** @hidden */
  79883. export var marbleProceduralTexturePixelShader: {
  79884. name: string;
  79885. shader: string;
  79886. };
  79887. }
  79888. declare module BABYLON {
  79889. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79890. private _numberOfTilesHeight;
  79891. private _numberOfTilesWidth;
  79892. private _amplitude;
  79893. private _jointColor;
  79894. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79895. updateShaderUniforms(): void;
  79896. get numberOfTilesHeight(): number;
  79897. set numberOfTilesHeight(value: number);
  79898. get amplitude(): number;
  79899. set amplitude(value: number);
  79900. get numberOfTilesWidth(): number;
  79901. set numberOfTilesWidth(value: number);
  79902. get jointColor(): BABYLON.Color3;
  79903. set jointColor(value: BABYLON.Color3);
  79904. /**
  79905. * Serializes this marble procedural texture
  79906. * @returns a serialized marble procedural texture object
  79907. */
  79908. serialize(): any;
  79909. /**
  79910. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79911. * @param parsedTexture defines parsed texture data
  79912. * @param scene defines the current scene
  79913. * @param rootUrl defines the root URL containing marble procedural texture information
  79914. * @returns a parsed Marble Procedural BABYLON.Texture
  79915. */
  79916. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79917. }
  79918. }
  79919. declare module BABYLON {
  79920. /** @hidden */
  79921. export var normalMapProceduralTexturePixelShader: {
  79922. name: string;
  79923. shader: string;
  79924. };
  79925. }
  79926. declare module BABYLON {
  79927. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79928. private _baseTexture;
  79929. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79930. updateShaderUniforms(): void;
  79931. render(useCameraPostProcess?: boolean): void;
  79932. resize(size: any, generateMipMaps: any): void;
  79933. get baseTexture(): BABYLON.Texture;
  79934. set baseTexture(texture: BABYLON.Texture);
  79935. /**
  79936. * Serializes this normal map procedural texture
  79937. * @returns a serialized normal map procedural texture object
  79938. */
  79939. serialize(): any;
  79940. /**
  79941. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79942. * @param parsedTexture defines parsed texture data
  79943. * @param scene defines the current scene
  79944. * @param rootUrl defines the root URL containing normal map procedural texture information
  79945. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79946. */
  79947. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79948. }
  79949. }
  79950. declare module BABYLON {
  79951. /** @hidden */
  79952. export var perlinNoiseProceduralTexturePixelShader: {
  79953. name: string;
  79954. shader: string;
  79955. };
  79956. }
  79957. declare module BABYLON {
  79958. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79959. time: number;
  79960. timeScale: number;
  79961. translationSpeed: number;
  79962. private _currentTranslation;
  79963. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79964. updateShaderUniforms(): void;
  79965. render(useCameraPostProcess?: boolean): void;
  79966. resize(size: any, generateMipMaps: any): void;
  79967. /**
  79968. * Serializes this perlin noise procedural texture
  79969. * @returns a serialized perlin noise procedural texture object
  79970. */
  79971. serialize(): any;
  79972. /**
  79973. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79974. * @param parsedTexture defines parsed texture data
  79975. * @param scene defines the current scene
  79976. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79977. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79978. */
  79979. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79980. }
  79981. }
  79982. declare module BABYLON {
  79983. /** @hidden */
  79984. export var roadProceduralTexturePixelShader: {
  79985. name: string;
  79986. shader: string;
  79987. };
  79988. }
  79989. declare module BABYLON {
  79990. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79991. private _roadColor;
  79992. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79993. updateShaderUniforms(): void;
  79994. get roadColor(): BABYLON.Color3;
  79995. set roadColor(value: BABYLON.Color3);
  79996. /**
  79997. * Serializes this road procedural texture
  79998. * @returns a serialized road procedural texture object
  79999. */
  80000. serialize(): any;
  80001. /**
  80002. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  80003. * @param parsedTexture defines parsed texture data
  80004. * @param scene defines the current scene
  80005. * @param rootUrl defines the root URL containing road procedural texture information
  80006. * @returns a parsed Road Procedural BABYLON.Texture
  80007. */
  80008. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  80009. }
  80010. }
  80011. declare module BABYLON {
  80012. /** @hidden */
  80013. export var starfieldProceduralTexturePixelShader: {
  80014. name: string;
  80015. shader: string;
  80016. };
  80017. }
  80018. declare module BABYLON {
  80019. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  80020. private _time;
  80021. private _alpha;
  80022. private _beta;
  80023. private _zoom;
  80024. private _formuparam;
  80025. private _stepsize;
  80026. private _tile;
  80027. private _brightness;
  80028. private _darkmatter;
  80029. private _distfading;
  80030. private _saturation;
  80031. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80032. updateShaderUniforms(): void;
  80033. get time(): number;
  80034. set time(value: number);
  80035. get alpha(): number;
  80036. set alpha(value: number);
  80037. get beta(): number;
  80038. set beta(value: number);
  80039. get formuparam(): number;
  80040. set formuparam(value: number);
  80041. get stepsize(): number;
  80042. set stepsize(value: number);
  80043. get zoom(): number;
  80044. set zoom(value: number);
  80045. get tile(): number;
  80046. set tile(value: number);
  80047. get brightness(): number;
  80048. set brightness(value: number);
  80049. get darkmatter(): number;
  80050. set darkmatter(value: number);
  80051. get distfading(): number;
  80052. set distfading(value: number);
  80053. get saturation(): number;
  80054. set saturation(value: number);
  80055. /**
  80056. * Serializes this starfield procedural texture
  80057. * @returns a serialized starfield procedural texture object
  80058. */
  80059. serialize(): any;
  80060. /**
  80061. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  80062. * @param parsedTexture defines parsed texture data
  80063. * @param scene defines the current scene
  80064. * @param rootUrl defines the root URL containing startfield procedural texture information
  80065. * @returns a parsed Starfield Procedural BABYLON.Texture
  80066. */
  80067. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  80068. }
  80069. }
  80070. declare module BABYLON {
  80071. /** @hidden */
  80072. export var woodProceduralTexturePixelShader: {
  80073. name: string;
  80074. shader: string;
  80075. };
  80076. }
  80077. declare module BABYLON {
  80078. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  80079. private _ampScale;
  80080. private _woodColor;
  80081. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  80082. updateShaderUniforms(): void;
  80083. get ampScale(): number;
  80084. set ampScale(value: number);
  80085. get woodColor(): BABYLON.Color3;
  80086. set woodColor(value: BABYLON.Color3);
  80087. /**
  80088. * Serializes this wood procedural texture
  80089. * @returns a serialized wood procedural texture object
  80090. */
  80091. serialize(): any;
  80092. /**
  80093. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  80094. * @param parsedTexture defines parsed texture data
  80095. * @param scene defines the current scene
  80096. * @param rootUrl defines the root URL containing wood procedural texture information
  80097. * @returns a parsed Wood Procedural BABYLON.Texture
  80098. */
  80099. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  80100. }
  80101. }